Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This is a simple REST API with node and express with typescript

NotificationsYou must be signed in to change notification settings

nmanikiran/rest-api-node-typescript

Repository files navigation

This is a simple REST API developed using node and express with typescript

alt text

❤️ Found this project useful?

If you found this project useful, then please consider giving it a ⭐️ on Github and sharing it with your friends via social media.

Requirements

Node.js,postgresql

Getting Started

Setup DB

  1. You need to install PostgreSQL

    • For Windows

      • Install PostgreSQL and set following environment variableC:\Program Files\PostgreSQL\10\bin,C:\Program Files\PostgreSQL\10\lib
    • For Ubuntu

      • Installationsudo apt updatesudo apt-get install postgresql postgresql-contrib

      • ManagePostgreSQL servicesudo systemctl {status | start | restart | stop} postgresql

  2. rename.env-sample to.env in the file the DB connection string need to be updated according to yourcredentials.ex :postgres://<YourUserName>:<YourPassword>@localhost:5432/<YourDatabase>

  3. you can find the DB and other details undersrc/dbcreate a database with the namenode-typescript-rest-api and then run/ import the.sql files (extract the sql files from sql.zip).Or you can runnpm run seed.

  4. installpm2 globally withnpm install -g pm2

Run the app locally

  • git clonehttps://github.com/nmanikiran/rest-api-node-typescript.git

  • npm install

  • npm start - This will start the application and run on port 3000

  • npm run dev - This will start the application in development mode

  • npm run watch & pm2 start ecosystem.config.js to start the application with cluster for scalability

you can change port in.env file check.env-sample

Folder Structure

src└───index.ts          # Application entry point└───routes            # Application routes / endpoints└───controllers       # Express route controllers for all the endpoints of the app└───repositories      # All the database interaction logic is here└───db                # DB related files like connection / seed data└───handlers          # Common logic└───logs              # application logs└───middlewares       # express middlewares└───models            # DB Models (Postgress)└───validators        # API Request object validations

Features

  • CRUD operations for Courses
  • CRUD operations for Lessons
  • REST API Request object validations - Basic
  • Error Logs
  • Setup docs
  • Seeder for DB

Planned

  • JWT login
  • Unit Testing
  • Postman collections
  • Improve request Object Validations
  • Improve Error Messages for request failures
  • Project / DB Setup in Ubuntu - Docs
  • Security
  • Hosting

REST Services

The application exposes a few REST endpoints

HTTPGET /api/lessons

HTTPGET /api/lessons/:id

HTTPGET /api/courses

You can use the following code snippet to call the secured endpoint:

fetch("http://localhost:3000/api/courses",{method:"GET",headers:{"Content-Type":"application/json",},}).then((response)=>{if(response.status===200){response.json().then((j)=>console.log(j));}else{console.log("ERROR",response.status);}}).catch((error)=>console.log(error));

Created & Maintained By

Mani Kiran
Mani Kiran N

💻📖🤔👀🚧
Tushar Gupta
Tushar Gupta

💻📖💬🚧

Feel free to reach out to me through @nmanikiran if you have any questions or feedback!

Recommended / Preferred

VSCode

Thanks & Credits to

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp