Skip to content

Commit

Permalink
feat: initial typescript setup completed
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakjdev committed Jul 7, 2022
1 parent ba84995 commit f73071e
Show file tree
Hide file tree
Showing 32 changed files with 3,342 additions and 745 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
./dist
20 changes: 15 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,40 @@ module.exports = {
node: true,
jest: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
project: ['./tsconfig.json'],
ecmaVersion: 2021,
},
extends: [
'eslint:recommended',
'airbnb-base',
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended'
],
plugins: [
'import',
],
rules: {
'import/extensions': [
'error',
'warn',
{
ts: true,
js: true,
svg: true,
json: true
},
],
'no-underscore-dangle': 'off',
'array-callback-return': 'off',
'newline-before-return': 'error',
'consistent-return': 'error',
'consistent-return': 'off',
'@typescript-eslint/naming-convention': 'off',
'no-else-return': ['error', { allowElseIf: false }],
'class-methods-use-this': 'off',
indent: ['error', 4, { SwitchCase: 1 }],
'@typescript-eslint/indent': ['error', 4, { SwitchCase: 1 }],
semi: ['error', 'never'],
'@typescript-eslint/semi': ['error', 'never'],
'no-multiple-empty-lines': ['error', { max: 1 }],
'max-len': 'off',
'new-cap': ['error', {
Expand All @@ -42,4 +52,4 @@ module.exports = {
}],
'prefer-const': 'error',
},
}
}
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Bug report
description: Create a bug report to help us address errors in the repository
title: "[BUG] <bug description>"
labels: [bug]
body:
- type: textarea
id: bugdescription
attributes:
label: Description of the bug
validations:
required: true
- type: textarea
id: workingenvironment
attributes:
label: Working Environment (e.g. operating system, browser, device)
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Please add screenshots (if applicable)
validations:
required: false
- type: textarea
id: context
attributes:
label: Add any other context about the problem here
validations:
required: false
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ideas
description: Have a new idea or feature request
title: "[FEATURE REQUEST] <description here>"
labels: [ideas]
body:
- type: textarea
id: description
attributes:
label: Description of feature request, idea
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Add (multiple) screenshot links (if applicable)
validations:
required: false
- type: textarea
id: context
attributes:
label: Add any other context about the feature request here
validations:
required: false
35 changes: 35 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: pull request
description: Create a pull request
title: "[PULL REQUEST] <pull request details>"
labels: [enhancement]
body:
- type: textarea
id: description
attributes:
label: Description of the changes, you have made.(Mention the issue number, it solves.)
validations:
required: true
- type: textarea
id: workingenvironment
attributes:
label: Mention if the changes are for any specific Working Environment (e.g. operating system, browser, device, N/A)
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Please add some pictorial references to these changes, if applicable (Drag & Drop your ss below)
validations:
required: false
- type: textarea
id: solution
attributes:
label: Does your code changes make any other feature broke? (If Yes, State reason)
validations:
required: true
- type: textarea
id: context
attributes:
label: Any other context or any note for reviewer, to add here regarding this change.
validations:
required: false
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: continuos-integration-checks
on:
push:
branches: [ main ]
jobs:
continuos-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2

- name: Install Dependencies
run: npm install

- name: Run eslint check
run: npm run lint

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
/dist
node_modules
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Sarthak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# base-ts-express-server-setup


You can clone this repo and start building your restful API in typescript using express.js

```
NOTE: Feedbacks for the scope of improvement and more code best practices are appreciated.
Raise an issue if facing error or bug.
```

## Connnect with me here:

- [Twitter](https://twitter.com/sarthakjdev)<br>
- [Linkedin](https://www.linkedin.com/in/sarthakjdev)
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
17 changes: 17 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.9'

services:
postgres:
container_name: crossknot-api
image: postgres
environment:
- POSTGRES_USER=crossknot
- POSTGRES_DB=crossknot
- POSTGRES_PASSWORD=crossknot
volumes:
- crossknot-data:/var/lib/postressql/data
ports:
- "5431:5432"

volumes:
crossknot-data:
2 changes: 2 additions & 0 deletions errors.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[2022-07-07T12:40:57.055Z] info: Server is listenning on 3000
[2022-07-07T12:49:35.895Z] info: Server is listenning on 3000
20 changes: 0 additions & 20 deletions index.js

This file was deleted.

24 changes: 24 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import express from 'express'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import dotenv from 'dotenv/config'
import config from '@configs/config'
import logger from '@utils/logger'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import cors from 'cors'

import ready from '@controllers/ready'
// requiring routes files :
import serverRoute from '@routes/index'

const port = config.PORT || 5000

const app = express()
app.use(cors())
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use('/', serverRoute)
app.get('/', ready)

app.listen(port, () => {
logger.info(`Server is listenning on ${port}`)
})
Loading

0 comments on commit f73071e

Please sign in to comment.