Skip to content

kartikpateldev/NodeJS_Express_Typescript_boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoilerPlate code for NodeJs-Express in Typescript

Reference: https://auth0.com/blog/node-js-and-typescript-tutorial-build-a-crud-api/

Next, initialize a Node.js project within the project directory by creating a package.json file with default settings:

npm init -y
npm i express dotenv cors helmet socket.io

Here's what each of the above packages does in your project:

express: Fast, unopinionated, minimalist web framework for Node.js.

dotenv: Zero-dependency module that loads environment variables from a .env file into process.env.

cors: Express middleware to enable CORS with various options.

helmet: Express middleware to secure your apps by setting various HTTP headers, which mitigate common attack vectors.

To use TypeScript, you also need to install a stable version of typescript as a developer dependency:

npm i -D typescript

To use TypeScript effectively, you need to install type definitions for the packages you installed previously:

npm i -D @types/node @types/express @types/cors 

Initialize TypeScript in Node.js

To help the TypeScript compiler understand your project's structure, you need to create a tsconfig.json file within the directory you want to use as the root directory of the TypeScript project. In this case, your project directory and the TypeScript project directory are the same.

To easily generate the tsconfig.json file, ensure that you are under the project directory and issue the following command:

npx tsc --init

Use Environmental Variables:

touch .env

Improve TypeScript Development Workflow

The TypeScript compilation process can increase the bootstrapping time of an application. However, you don't need to recompile the entire project whenever there's a change in its source code. You can set up ts-node-dev to significantly decrease the time it takes to restart your application when you make a change.

Start by installing this package to power up your development workflow:

npm i -D ts-node-dev

Creating CRUD operation for item:

mkdir src/items
touch src/items/item.interface.ts
touch src/items/items.interface.ts
touch src/items/items.service.ts
touch src/items/items.router.ts

For downloading insta reel, open link get videUrl from javacript data in headers, open it and it will redirect to cdn link and download that video from redirected link.

About

Boilerplate code for NodeJS with Express in Typescript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published