Rest Api Node Typescript

This is a simple REST API with node and express with typescript
Alternatives To Rest Api Node Typescript
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Nodebestpractices87,387
5 days ago36cc-by-sa-4.0JavaScript
:white_check_mark: The Node.js best practices list (March 2023)
Express60,3721,122,97879,5044 days ago299April 29, 2022155mitJavaScript
Fast, unopinionated, minimalist web framework for node.
Fiber25,36165611 hours ago275September 08, 202239mitGo
⚡️ Express inspired web framework written in Go
Passport21,29581,2723,9165 days ago32May 20, 2022363mitJavaScript
Simple, unobtrusive authentication for Node.js.
Javascript Testing Best Practices21,034
13 days ago55mitJavaScript
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (December 2022)
N Blog14,445
3 years ago17JavaScript
《一起学 Node.js》
Apollo Server13,2785,3261,1532 days ago305August 26, 202240mitTypeScript
🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
Mean12,176
3 months agoFebruary 02, 201749TypeScript
The MEAN stack uses Mongo, Express, Angular(6) and Node for simple and scalable fullstack js applications
Postgraphile11,8607699a month ago156May 25, 202263mitTypeScript
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!
Node Elm11,215
a year ago62gpl-2.0JavaScript
基于 node.js + Mongodb 构建的后台系统
Alternatives To Rest Api Node Typescript
Select To Compare


Alternative Project Comparisons
Readme

REST API with Node using Typescript

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 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://<YourUserName>:<YourPassword>@localhost:5432/<YourDatabase>

  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:

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

Popular Express Projects
Popular Nodejs Projects
Popular Frameworks Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Es2017
Es6
Typescript
Node
Express
Rest
Postgresql
Validation
Rest Api
Logger
Webservice
Sequelize
Nodemon
Helmet