Skip to content

A template to get you started with TypeScript, Node.JS & Express with MongoDB as the backend for the REST API.

License

Notifications You must be signed in to change notification settings

sande265/node-typescript-starter

Repository files navigation

Node.JS TypeScript JavaScript Eslint Prettier

Don't forget give me a star if you like it 😅😅 😊😊

The 2nd project what I did with Nodejs, Express & TypeScript.

  • Node.js
  • Express
  • Concurrently
  • Typescript
  • mongodb

Security

Generate Private key & Public Key for the app to authenticate using the keys generated to sign the token.

openssl genrsa -des3 -out private.pem 2048

then generate public key from private.pem

openssl rsa -in private.pem -outform PEM -pubout -out public.pem

(Optional)

  • Rename the keys with extenstion .key

  • Move All the files to the root of the app & also change the format of key if its not .key!

Environment variables use pattern

PORT=// Your app port here for development
SECRET=// app secret used to sign the keys (Required)
TOKEN_EXP=// Token expiry time in seconds, default=3600
RT_EXPIRY=// Refresh token expiry time in seconds, default=2*TOKEN_EXPIRY
DB_USER=// MongoDB Username
DB_PASS=// MongoDB Password
DB_PORT=// MongoDB Server Port
DB_HOST=// Atlas DB url or your hosted url endpoint

To use the environment variables use dotenv.config() to access the values or else it's undefined!

Use the package manager [YARN] or [NPM] to install [App].
First, Install API image classification: Here
Edit src/constant/index.ts

git clone https://github.com/sande265/node-typescript-starter.git
cd node-typescript-starter
yarn install || npm install

Installation

npm install -g nodemon
npm install -g ts-node
npm install -g typescript
npm install

Usage

yarn dev // using concurrently to compile TS to JS & run dev server.
yarn build // For production

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Releases

No releases published

Packages

No packages published