Music.Streaming.Microservice.mp4
-
npx tsc --init- Initialize TypeScript configuration. -
Updated TypeScript configuration (tsconfig.json):
- Set
"module": "NodeNext"to Enables modern Node.js ESM (import/export) - Set
"target": "ES2020"for Compiles TS into modern JavaScript
- Set
-
Install dependencies & their TypeScript type definitions:
npm i express mongoose dotenv bcrypt jsonwebtoken concurrently nodemon && npm i -D @types/express @types/mongoose @types/bcrypt @types/jsonwebtoken @types/dotenvtype definitions are needed for safer, clearer, and more maintainable code by explicitly defining the expected types of data and interfaces, enhancing both development and runtime robustness.npm i cors @types/cors
-
Setup
package.jsonscripts for easier development and running:"build": "tsc"π Compiles all TypeScript (.ts) files into JavaScript inside the dist folder."start": "node dist/index.js"π Runs the compiled JavaScript app from the dist folder in production."dev": "concurrently \"tsc -w\" \"nodemon dist/index.js\""π Runs TypeScript compiler in watch mode AND restarts the server automatically whenever files change.
-
Set your
.env fileexactly similar to.env.examplefile & add the required details init.
-
Same tsconfig.json configuration.
-
Install dependencies & their TypeScript type definitions:
npm i express dotenv @types/express @types/dotenv cloudinarynpm i -D nodemon typescript concurrentlynpm i @neondatabase/serverless- to use neon Postgressqlnpm i multer axios dataurinpm i @types/multernpm i cors @types/cors
-
Follow the same setup in your
.envfile similar to.env.examplefile in admin-service. [PORT, DB_URL, CLOUDINARY-SECRETS] -
Redis setup:
npm i redis @types/redis- Follow the Redis config on
index.tsfile - Set your
.env fileexactly similar to.env.examplefile & add the required details init.
-
Same tsconfig.json configuration.
-
Install dependencies & their TypeScript type definitions:
npm i express dotenv @types/express @types/dotenvnpm i @neondatabase/serverless- to use neon Postgressqlnpm i -D nodemon typescript concurrentlynpm i cors @types/cors
-
Redis setup:
npm i redis @types/redis- Follow the Redis config on
index.tsfile - Set your
.env fileexactly similar to.env.examplefile & add the required details init.