Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PORT=4000
NODE_ENV=development
APP_NAME="My Application"

CORS_ALLOWED_ORIGINS=http://localhost:3000,https://app.mywebsite.com

REDIS_URI=redis://127.0.0.1:6379
MONGODB_URI=mongodb://127.0.0.1:27017/node-starter

AWS_S3_BUCKET=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

SENTRY_DSN=
20 changes: 20 additions & 0 deletions backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
env: {
es2021: true,
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"indent": "off",
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"@typescript-eslint/no-explicit-any": "off",
},
};
15 changes: 15 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.DS_Store
node_modules

# production env files
.env

# exclude files in uploads
public/uploads/*
!public/uploads/.gitkeep

# exclude files in dist
dist/

# Sentry Config File
.sentryclirc
14 changes: 14 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 300,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "consistent",
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "auto"
}
5 changes: 5 additions & 0 deletions backend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"eslint.codeActionsOnSave.rules": null
}
98 changes: 98 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<img src="public/favicon.ico" height="100" width="100">

# nodejs-boilertemplate

Description of the project goes here.

---

## Setup & usage

**1. Install all dependencies**

```bash
yarn install
```

**2. Start the development server**

```bash
yarn dev
```

**3. Open [http://localhost:4000](http://localhost:4000) with your browser to see if the server is up.**

---

## Naming Conventions

### Classes and Types
When naming classes and types, use PascalCase.

```typescript
class MyClass {
// ...
}

type MyType = {
// ...
};
```

### Functions and Variables
When naming functions and variables, use camelCase.

```typescript
const myFunction = () => {
// ...
};

const myVariable = 0;
```

### Database Columns or Data In/Out
for database columns & response payloads, use snake_case.

```json
{
"first_name": "John",
"last_name": "Doe"
}
```

---

## API Testing Client

Download and install the latest version of Bruno from [here](https://www.usebruno.com/downloads).

After installing:
- open Bruno
- click on the `+` button to open a new collection
- navigate and select the folder `api-client-doc` in the root directory of the project

You should now see the collection in the Bruno app.

PS: _as you make changes (add or delete) the endpoints, the change is persisted to the `api-client-doc` folder_

---

## Contribution Guide

### Git Contribution

> Perform all your changes on a fork of the base repository.

> Open a pull request once you have completed your changes.

> Don't forget to sync your fork and pull frequently in case any new changes that have been made to the base repository may conflict with your changes.

---

### File Formatting

The same prettier config will be used for code formatting. It should be automatically applied when you use the VS Code prettier extension. If you are using something other than VS Code, try to see if a prettier extension is available for that.

---

_official policy: it is fOrBiddEn to bring down production with your PRs !!_
11 changes: 11 additions & 0 deletions backend/api-client-doc/Ping Test.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: Ping Test
type: http
seq: 1
}

get {
url: {{API_BASE_URL}}
body: none
auth: none
}
9 changes: 9 additions & 0 deletions backend/api-client-doc/bruno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "1",
"name": "Code-Challenge",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}
7 changes: 7 additions & 0 deletions backend/api-client-doc/collection.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
auth {
mode: bearer
}

auth:bearer {
token: {{ACCESS_TOKEN}}
}
4 changes: 4 additions & 0 deletions backend/api-client-doc/environments/development.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vars {
API_BASE_URL: http://localhost:4000
ACCESS_TOKEN:
}
23 changes: 23 additions & 0 deletions backend/api-client-doc/v1/auth/Login.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
meta {
name: Login
type: http
seq: 1
}

post {
url: {{API_BASE_URL}}/v1/auth/login
body: json
auth: none
}

body:json {
{
"email": "[email protected]",
"password": "password"
}
}

script:post-response {
// Set the access token var
bru.setEnvVar("ACCESS_TOKEN", res.body.data.token.access_token);
}
17 changes: 17 additions & 0 deletions backend/api-client-doc/v1/auth/Logout.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta {
name: Logout
type: http
seq: 8
}

post {
url: {{API_BASE_URL}}/v1/auth/logout
body: json
auth: none
}

body:json {
{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NWU3OGFiZGU1Y2I1N2RkYTc5YzQyOGEiLCJyZWZyZXNoVG9rZW4iOiJhOTgzMjZjNjlkYjQ3ZDQ4NWY3ZmRhMDAwMTBhMjlmNTE2YmMwOWEyMGQ5MDk2M2E4NTA4MDBhNTdiNzYzYjcwIiwiaWF0IjoxNzA5Njc1OTI2LCJleHAiOjE3MTIyNjc5MjZ9.qdwhsh8P76jVRqWxn1SfUOIuLMuBRnrn7ctwz8txp8o" // optional
}
}
17 changes: 17 additions & 0 deletions backend/api-client-doc/v1/auth/Refresh Tokens.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta {
name: Refresh Tokens
type: http
seq: 7
}

post {
url: {{API_BASE_URL}}/v1/auth/refresh-tokens
body: json
auth: none
}

body:json {
{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NWU3OGFiZGU1Y2I1N2RkYTc5YzQyOGEiLCJyZWZyZXNoVG9rZW4iOiJhOTgzMjZjNjlkYjQ3ZDQ4NWY3ZmRhMDAwMTBhMjlmNTE2YmMwOWEyMGQ5MDk2M2E4NTA4MDBhNTdiNzYzYjcwIiwiaWF0IjoxNzA5Njc1OTI2LCJleHAiOjE3MTIyNjc5MjZ9.qdwhsh8P76jVRqWxn1SfUOIuLMuBRnrn7ctwz8txp8o"
}
}
25 changes: 25 additions & 0 deletions backend/api-client-doc/v1/auth/Register.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
meta {
name: Register
type: http
seq: 2
}

post {
url: {{API_BASE_URL}}/v1/auth/register
body: json
auth: none
}

body:json {
{
"first_name": "John",
"last_name": "Olatubosun",
"email": "[email protected]",
"password": "password"
}
}

script:post-response {
// Set the access token var
bru.setEnvVar("ACCESS_TOKEN", res.body.data.token.access_token);
}
17 changes: 17 additions & 0 deletions backend/api-client-doc/v1/auth/Request Email Verification.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta {
name: Request Email Verification
type: http
seq: 3
}

post {
url: {{API_BASE_URL}}/v1/auth/request-email-verification
body: json
auth: none
}

body:json {
{
"user_id": "65e78abde5cb57dda79c428a"
}
}
17 changes: 17 additions & 0 deletions backend/api-client-doc/v1/auth/Request Password Reset.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta {
name: Request Password Reset
type: http
seq: 5
}

post {
url: {{API_BASE_URL}}/v1/auth/request-password-reset
body: json
auth: none
}

body:json {
{
"email": "[email protected]"
}
}
19 changes: 19 additions & 0 deletions backend/api-client-doc/v1/auth/Reset Password.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: Reset Password
type: http
seq: 6
}

patch {
url: {{API_BASE_URL}}/v1/auth/reset-password
body: json
auth: none
}

body:json {
{
"user_id": "65e78abde5cb57dda79c428a",
"reset_otp": "ec3bfd30761dd79f493e809ab4daf1536332ee70e996363a940e244fef02bf60",
"new_password": "new_password"
}
}
19 changes: 19 additions & 0 deletions backend/api-client-doc/v1/auth/Verify Email.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: Verify Email
type: http
seq: 4
}

post {
url: {{API_BASE_URL}}/v1/auth/verify-email
body: json
auth: none
}

body:json {
{
"user_id": "660801fd08ef6cf49ed1f118",
"verification_otp": "f52483d7d6bf0a66b87c2254b799104f3c0e73ca5beb5fce2e90c82ca748af47" // can be token or code
}

}
15 changes: 15 additions & 0 deletions backend/api-client-doc/v1/users/Get Current Session.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: Get Current Session
type: http
seq: 1
}

get {
url: {{API_BASE_URL}}/v1/users/session
body: none
auth: inherit
}

auth:bearer {
token: {{ACCESS_TOKEN}}
}
Loading