Skip to content

Commit 6e66dc2

Browse files
committed
Updated readme
1 parent 48788e5 commit 6e66dc2

File tree

4 files changed

+171
-327
lines changed

4 files changed

+171
-327
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
### Node ###
55
# Logs
6-
logs
76
*.log
87
npm-debug.log*
98
yarn-debug.log*

Readme.MD

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ If you found this project useful, then please consider giving it a ⭐️ on Git
1212

1313
[Node.js](https://nodejs.org/en/), [postgresql](https://www.postgresql.org/download/)
1414

15-
## Setup DB
15+
### Getting Started
16+
17+
### Setup DB
1618

1719
1. You need to install PostgreSQL
1820

19-
- For Windows
20-
- Install PostgreSQL and set following environment variable
21-
`C:\Program Files\PostgreSQL\10\bin`,
22-
`C:\Program Files\PostgreSQL\10\lib`
23-
- For Ubuntu
2421

25-
- Installation
26-
`sudo apt update`
27-
`sudo apt-get install postgresql postgresql-contrib`
22+
- For Windows
23+
- Install PostgreSQL and set following environment variable
24+
`C:\Program Files\PostgreSQL\10\bin`,
25+
`C:\Program Files\PostgreSQL\10\lib`
26+
- For Ubuntu
27+
28+
- Installation
29+
`sudo apt update`
30+
`sudo apt-get install postgresql postgresql-contrib`
2831

29-
- Manage `PostgreSQL` service
30-
`sudo systemctl {status | start | restart | stop} postgresql`
32+
- Manage `PostgreSQL` service
33+
`sudo systemctl {status | start | restart | stop} postgresql`
3134

3235
2. rename `.env-sample` to `.env` in the file the DB connection string need to be updated according to your `credentials`.
3336
ex : `postgres://<YourUserName>:<YourPassword>@localhost:5432/<YourDatabase>`
@@ -36,7 +39,7 @@ If you found this project useful, then please consider giving it a ⭐️ on Git
3639
create a database with the name `node-typescript-rest-api` and then run/ import the `.sql` files (extract the sql files from sql.zip).
3740
Or you can run `npm run seed`.
3841

39-
## Run the app locally
42+
### Run the app locally
4043

4144
- git clone https://github.com/nmanikiran/rest-api-node-typescript.git
4245

@@ -46,6 +49,22 @@ If you found this project useful, then please consider giving it a ⭐️ on Git
4649

4750
you can change port in `.env` file check `.env-sample`
4851

52+
## Folder Structure
53+
54+
```
55+
src
56+
└───index.ts # Application entry point
57+
└───routes.ts # Application routes / endpoints
58+
└───controllers # Express route controllers for all the endpoints of the app
59+
└───db # DB related files like connection / seed data
60+
└───handlers # Common logic
61+
└───logs # application logs
62+
└───models # DB Models (Postgress)
63+
└───repositories # All the database interaction logic is here
64+
└───validators # API Request object validations
65+
66+
```
67+
4968
## Features
5069

5170
- CRUD operations for Courses
@@ -66,6 +85,32 @@ you can change port in `.env` file check `.env-sample`
6685
- \[ ] Security
6786
- \[ ] Hosting
6887

88+
## REST Services
89+
90+
The application exposes a few REST endpoints
91+
92+
`HTTP` `GET` /api/lessons
93+
`HTTP` `GET` /api/lessons/:id
94+
`HTTP` `GET` /api/courses
95+
You can use the following code snippet to call the secured endpoint:
96+
97+
```js
98+
fetch("http://localhost:3000/api/courses", {
99+
method: "GET",
100+
headers: {
101+
"Content-Type": "application/json",
102+
},
103+
})
104+
.then((response) => {
105+
if (response.status === 200) {
106+
response.json().then((j) => console.log(j));
107+
} else {
108+
console.log("ERROR", response.status);
109+
}
110+
})
111+
.catch((error) => console.log(error));
112+
```
113+
69114
## Contributing
70115

71116
Awesome! Contributions of all kinds are greatly appreciated. To help smoothen the process we have a few non-exhaustive guidelines to follow which should get you going in no time.

0 commit comments

Comments
 (0)