百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rest-api-node-typescript

> 后端框架
开源

这是一个使用 node 和 express 以及 TypeScript 的简单 REST API

199 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

这是一个使用 node 和 express 以及 TypeScript 的简单 REST API

REST API with Node using Typescript

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

❤️ 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 variable C:\Program Files\PostgreSQL\10\bin, C:\Program Files\PostgreSQL\10\lib
    • For Ubuntu

      • Installation sudo apt update sudo apt-get install postgresql postgresql-contrib

      • Manage PostgreSQL service sudo 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 your credentials. ex : postgres://:@localhost:5432/

  3. you can find the DB and other details under src/db create a database with the name node-typescript-rest-api and then run/ import the .sql files (extract the sql files from sql.zip). Or you can run npm run seed.

  4. install pm2 globally with npm install -g pm2

Run the app locally

  • git clone https://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
  • [x] Postman collections
  • [ ] Improve request Object Validations
  • [ ] Improve Error Messages for request failures
  • [x] Project / DB Setup in Ubuntu - Docs
  • [ ] Security
  • [ ] Hosting

REST Services

The application exposes a few REST endpoints

HTTP GET /api/lessons

HTTP GET /api/lessons/:id

HTTP GET /api/courses

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

javascript
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 N

Tushar Gupta

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

Recommended / Preferred

VSCode

Thanks & Credits to

  • Envato Tuts+ 30 Days to Learn HTML & CSS (Full Course)
  • Wes Bos JavaScript30
  • CodeWorkr REST API with Node (Express & MongoDB)
  • Tyler McGinnis Advanced JavaScript

Issues· 3 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptes2017es6expresshelmet

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架