Skip to content

Commit

Permalink
fix: Run examples without NX (#695)
Browse files Browse the repository at this point in the history
* fix: fix examples

* docs: fix readme
  • Loading branch information
Aman035 authored Sep 4, 2023
1 parent 5831caf commit 0d5e098
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 142 deletions.
18 changes: 0 additions & 18 deletions packages/examples/sdk-backend-node/.eslintrc.json

This file was deleted.

24 changes: 15 additions & 9 deletions packages/examples/sdk-backend-node/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ git clone https://github.com/ethereum-push-notification-service/push-sdk.git
cd push-sdk
yarn install
```
***Note*** - We are using `yarn` and **strongly** advise to use yarn 1.x to avoid any NPM issues.

## Setting up the SDK-Backend-Node
**_Note_** - We are using `yarn` and **strongly** advise to use yarn 1.x to avoid any NPM issues.

## Setting up the SDK-Backend-Node

1. Navigate to the `packages/examples/sdk-backend-node` directory.
```bash
cd packages/examples/sdk-backend-node
```
2. Set up your environment variables by creating a `.env` file based on the provided `.env.sample` file.
3. Install the node dependencies
```bash
yarn install
```

## Running the SDK-Backend-Node
### By GUI (preferred)
1. Click on the `NX console` extension icon in the VSCode sidebar.
2. Click on the `serve` target execute icon under `examples-sdk-backend-node`
## Running the SDK-Backend-Node

### By CLI
1. Navigate to the root level of push-sdk repository.
2. Run `yarn nx serve packages/examples/sdk-backend-node`
```bash
yarn start
```
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ async function PushAPI_nft_user_create(silent = !showAPIResponse) {
account: nftAccount1,
signer: nftSigner1,
env: env as ENV,
additionalMeta: { NFTPGP_V1: { password: nftProfilePassword1 } },
additionalMeta: { NFTPGP_V1: { password: nftProfilePassword1 as string } },
});

const user2 = await PushAPI.user.create({
account: nftAccount2,
signer: nftSigner2,
env: env as ENV,
additionalMeta: { NFTPGP_V1: { password: nftProfilePassword2 } },
additionalMeta: { NFTPGP_V1: { password: nftProfilePassword2 as string } },
});

console.log('PushAPI_nft_user_create | Response - 200 OK');
Expand Down
16 changes: 0 additions & 16 deletions packages/examples/sdk-backend-node/jest.config.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum ENV {
const { env, showAPIResponse } = config;

// If you own a channel, you can use your channel address as well
const channelPrivateKey: string = process.env.WALLET_PRIVATE_KEY;
const channelPrivateKey = process.env.WALLET_PRIVATE_KEY;

/***************** SAMPLE SIGNER GENERATION *********************/
/**
Expand Down Expand Up @@ -170,7 +170,7 @@ async function PushAPI_user_getSubscriptions(silent = !showAPIResponse) {
// Push Notification - PushAPI.channels.getChannel
async function PushAPI_channels_getChannel(silent = !showAPIResponse) {
const channelData = await PushAPI.channels.getChannel({
channel: channelAddress,
channel: channelAddress as string,
env: env as ENV,
});

Expand Down
17 changes: 17 additions & 0 deletions packages/examples/sdk-backend-node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "sdk-backend-node",
"version": "1.0.0",
"description": "Welcome to the SDK Backend Node Example project, a hands-on guide demonstrating how to leverage the power of Push Protocol in a backend environment using Node.js. This resource is an invaluable companion for developers keen to integrate Push Protocol into their backend services. Dive into the code to gain a comprehensive understanding of how to deploy various features of the Push Protocol in a Node.js backend.",
"main": "index.js",
"scripts": {
"start": "ts-node main.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@pushprotocol/restapi": "^1.4.17",
"@pushprotocol/socket": "^0.5.2"
}
}
52 changes: 0 additions & 52 deletions packages/examples/sdk-backend-node/project.json

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions packages/examples/sdk-backend-node/tsconfig.app.json

This file was deleted.

13 changes: 0 additions & 13 deletions packages/examples/sdk-backend-node/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/examples/sdk-backend-node/tsconfig.spec.json

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ const { env } = config;
const signer = ethers.Wallet.createRandom();

// Video Data
const videoChainId = +process.env.VIDEO_CHAIN_ID;
const videoChainId = +(process.env.VIDEO_CHAIN_ID as string);
let videoData = PushAPI.video.initVideoCallData;
const videoSetData: (
fn: (data: PushAPI.VideoCallData) => PushAPI.VideoCallData
) => void = (fn) => {
videoData = fn(videoData);
};
let videoObject = null;
let videoObject: any = null;
const videoLocalStream = null; // get the local stream
const videoSenderAddress = process.env.VIDEO_SENDER_ADDRESS;
const videoRecipientAddress = process.env.VIDEO_RECIPEINT_ADDRESS;
const videoChatId = process.env.VIDEO_CHAT_ID;
let videoSignalData_1 = null;
let videoSignalData_1: any = null;

const skipExample = () => {
const requiredEnvVars = [
Expand Down Expand Up @@ -146,7 +146,7 @@ async function PushAPI_video_disconnect() {

async function PushVideoSDKSocket() {
const pushSDKSocket = createSocketConnection({
user: videoSenderAddress,
user: videoSenderAddress as string,
socketType: 'chat',
socketOptions: { autoConnect: true, reconnectionAttempts: 3 },
env: env as ENV,
Expand Down
1 change: 0 additions & 1 deletion workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": 2,
"projects": {
"demonative": "apps/demonative",
"examples-sdk-backend-node": "packages/examples/sdk-backend-node",
"examples-sdk-frontend-react": "packages/examples/sdk-frontend-react",
"ledgerlive": "packages/ledgerlive",
"reactnative": "packages/reactnative",
Expand Down

0 comments on commit 0d5e098

Please sign in to comment.