This project was bootstrapped with Fastify-CLI.
The website is deployed in Render at: https://ejs-with-node.onrender.com/api/v1/ This project is clone of another repo rojandahal/node-fastify-postgres with additional feature which includes the dynamic template using ejs. It provide server side rendering with ejs templating engine.
git clone https://github.com/rojandahal/node-fastify-postgres.git
-git checkout feature/local-auth
: Implements local authentication with postgres with username and password.
-git checkout feature/session-auth
: Implements session in local authentication and stores the session in cookies.
-git checkout feature/oauth-google
: Extends feature/session-auth
and implements "Sign in with google" and stores session
and also implements creation of task and fetching of task with user verification improved for both local and OAuth.
Install dependencies in app with npm
npm install
In the project directory, you can run:
To start the app in dev mode.
Open http://localhost:3000 to view it in the browser.
For production mode
Run the test cases.
To learn Fastify, check out the Fastify documentation.
To run this project, you will need to add the following environment variables to your .env file
API_VERSION=
SECRET_KEY=
SESSION_SECRET=
GOOGLE_OAUTH_CLIENT_ID=
GOOGLE_OAUTH_CLIENT_SECRET=
GOOGLE_OAUTH_REDIRECT=
baseURL=
POST /api/v1/signup
Body | Type | Description |
---|---|---|
email |
string |
Required |
username |
string |
Required, Unique |
password |
string |
Required |
POST /api/v1/login
Body | Type | Description |
---|---|---|
username |
string |
Required |
password |
string |
Required |
POST /api/v1/logout
Header | Type | Description |
---|---|---|
token |
string |
Required. The token of logged-in user |
GET /api/v1/users/
Header | Type | Description |
---|---|---|
token |
string |
Required. The token of logged-in user |
GET /api/v1/users/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. The id of the user |
token (Header) |
string |
Required. The token of logged-in user |
POST /api/v1/users/:id
Body | Type | Description |
---|---|---|
username |
string |
Required. The new username of the user |
Parameter | Type | Description |
---|---|---|
id |
string |
Required. The id of the user |
token (Header) |
string |
Required. The token of logged-in user |
POST /api/v1/users/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. The id of the user |
token (Header) |
string |
Required. The token of logged-in user |
GET /api/v1/login/google
POST /api/v1/tasks/
Body | Type | Description |
---|---|---|
title |
string |
Required. The title of task |
description |
string |
The description of task |
status |
string |
The status of task |
GET /api/v1/users/:id
Header | Type | Description |
---|---|---|
token |
string |
Required. The token of logged-in user |