Documentation
Environment setup

Environment setup

Follow the steps to setup the project environment.

Create folder

mkdir -p tsdk-quickstart/server/src
cd tsdk-quickstart

Initialize package.json:

pnpm init

Setting pnpm monorepo:

pnpmConfig='
packages:
 
  - ./**
 
  # exclude projects in dist folder
  - "!**/dist*/**"
  # exclude .next projects
  - "!**/.next/**"
'
echo $pnpmConfig > pnpm-workspace.yaml

Switch to directory ./server, initialize server/package.json:

cd server
pnpm init

Install dependencies in ./server:

pnpm add express socket.io tsdk-server-adapters
pnpm add typescript @types/node @types/express tsdk @nestjs/cli -D

Create tsconfig.json:

config='{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": false,
    "removeComments": true,
    "esModuleInterop": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "strictNullChecks": true,
    "target": "es2017",
    "sourceMap": true,
    "baseUrl": "./",
    "outDir": "./build",
    "paths": {
      "@/*": ["./*"]
    },
    "incremental": true,
    "skipLibCheck": true
  },
  "exclude": ["./next-app"]
}'
echo $config > tsconfig.json

Generate config file: tsdk.config.js

In directory ./server, run below command to generate tsdk.config.js(tsdk.config README):

pnpm tsdk --init

Update tsdk.config.js config content:

/** @type {import('tsdk').TSDKConfig} */
module.exports = {
  packageDir: '../',
  packageName: 'fe-sdk',
  baseDir: './src',
  entityLibName: ['typeorm'],
  entityExt: 'entity',
  apiconfExt: 'apiconf',
  shareExt: 'shared',
  sharedDirs: ['./src/shared'],
  removeFields: [],
  monorepoRoot: '../',
  dataHookLib: 'SWR',
  dependencies: {
    axios: '1.6.2',
  },
};

Run command to install dependencies:

pnpm i

Export module

Switch to directory ./server, run commands to generate fe-sdk folder:

pnpm tsdk --sync
      • tsdk.config.js
      • package.json
    • package.json
    • pnpm-workspace.yaml
  • Folder and file explain:

    • ./server/tsdk.config.js - tsdk's config file More
    • .vscode/tsdk.code-snippets - tsdk code snippets More
    • ./server/src/shared - shared folder (will copy to fe-sdk)
    • ./fe-sdk - the exported module
    Last updated on