- Notifications
You must be signed in to change notification settings - Fork50
nmanikiran/rest-api-node-typescript
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a simple REST API developed using node and express with typescript
If you found this project useful, then please consider giving it a ⭐️ on Github and sharing it with your friends via social media.
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
- Install PostgreSQL and set following environment variable
For Ubuntu
Installation
sudo apt update
sudo apt-get install postgresql postgresql-contrib
Manage
PostgreSQL
servicesudo systemctl {status | start | restart | stop} postgresql
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>
you can find the DB and other details under
src/db
create 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
.install
pm2
globally withnpm install -g pm2
git clonehttps://github.com/nmanikiran/rest-api-node-typescript.git
npm install
npm start
- This will start the application and run on port 3000npm run dev
- This will start the application in development modenpm 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
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
- CRUD operations for Courses
- CRUD operations for Lessons
- REST API Request object validations - Basic
- Error Logs
- Setup docs
- Seeder for DB
- JWT login
- Unit Testing
- Postman collections
- Improve request Object Validations
- Improve Error Messages for request failures
- Project / DB Setup in Ubuntu - Docs
- Security
- Hosting
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));
Mani Kiran N 💻📖🤔👀🚧 | Tushar Gupta 💻📖💬🚧 |
Feel free to reach out to me through @nmanikiran if you have any questions or feedback!
- Envato Tuts+30 Days to Learn HTML & CSS (Full Course)
- Wes BosJavaScript30
- CodeWorkrREST API with Node (Express & MongoDB)
- Tyler McGinnisAdvanced JavaScript
About
This is a simple REST API with node and express with typescript
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.