Skip to content

Commit 5d4436a

Browse files
committed
Bootstrapping.
0 parents  commit 5d4436a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10018
-0
lines changed

.env.example

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# JWT
2+
AUTH_TOKEN_EXPIRATION_TIME=""
3+
AUTH_TOKEN_SECRET=""
4+
5+
# DATABASE
6+
DB_HOST=""
7+
DB_NAME=""
8+
DB_PASSWORD=""
9+
DB_PORT=""
10+
DB_USERNAME=""
11+
DB_MAIN_SCHEMA=""
12+
DB_AUDIT_SCHEMA=""
13+
14+
# LOGGING
15+
LOGGING_COMBINED_FILE=""
16+
LOGGING_ERROR_FILE=""
17+
LOGGING_LEVEL=""
18+
LOGGING_TYPE=""
19+
20+
# SERVER
21+
SERVER_PORT=""

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.idea/
2+
.vscode/
3+
node_modules/
4+
coverage/
5+
build/
6+
tmp/
7+
temp/
8+
*.log
9+
.env
10+
.env.*
11+
!.env.example
12+
*.cert
13+
*.key

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Prosper Otemuyiwa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# PostgreSQL, TypeScript, Node.js and Express.js Stack
2+
3+
## Overview
4+
5+
This repo is a boilerplate project starter built with TypeScript for a PostgreSQL / Express.js / Node.js backend service. You can plug-in any other frontend library seamlessly.
6+
7+
## Technologies Used
8+
9+
- [PostgreSQL](https://www.postgresql.org/) - The World's Most Advanced Open Source Relational Database
10+
- [Typescript](https://www.typescriptlang.org/) - TypeScript extends JavaScript by adding types to the language
11+
- [Node.js](https://nodejs.org/en/) - Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
12+
- [Express.js](https://expressjs.com/) - Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
13+
- [TypeORM](https://typeorm.io/#/) - TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8)
14+
15+
## Highlights
16+
17+
- [PostgreSQL Audit Trail]()
18+
- Test Coverage
19+
![](https://leo.d.pr/kmVY0g+)
20+
- [Decorators and more]()
21+
22+
23+
## Folders / Files Structure
24+
25+
Here is a high-level overview of our file structure.
26+
27+
```
28+
src/
29+
__tests__/ # tests
30+
config/
31+
packages/
32+
api/ # API helpers, middlewares, resources, controllers, validations
33+
database/ # database helpers, models, database migrations
34+
index.ts
35+
server.ts
36+
README.md
37+
package.json, etc...
38+
```
39+
40+
## Environment Variables
41+
42+
```
43+
# JWT
44+
AUTH_TOKEN_EXPIRATION_TIME=""
45+
AUTH_TOKEN_SECRET=""
46+
47+
# DATABASE
48+
DB_HOST=""
49+
DB_NAME=""
50+
DB_PASSWORD=""
51+
DB_PORT=""
52+
DB_USERNAME=""
53+
DB_MAIN_SCHEMA=""
54+
DB_AUDIT_SCHEMA=""
55+
56+
# LOGGING
57+
LOGGING_COMBINED_FILE=""
58+
LOGGING_ERROR_FILE=""
59+
LOGGING_LEVEL=""
60+
LOGGING_TYPE=""
61+
62+
# SERVER
63+
SERVER_PORT=""
64+
```
65+
66+
## Setup
67+
68+
1. Create a `.env.local` file on the root of the project based on `.env.example`
69+
2. Execute `npm run setup:local`
70+
3. Start the development server running `npm run dev`
71+
72+
## Running Tests
73+
74+
1. Create a `.env.test` file on the root of the project based on `.env.example`
75+
2. Execute `npm run setup:test`
76+
3. Run `npm test`
77+
78+
![](https://leo.d.pr/CYYAre+)
79+
80+
### License
81+
This project is open-sourced software licensed under the [MIT license](https://github.com/busayo/meanmap/blob/master/LICENSE).

custom.d.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Server } from 'http'
2+
3+
declare global {
4+
namespace NodeJS {
5+
interface Global {
6+
__appServer__: Server,
7+
}
8+
}
9+
// namespace jest {
10+
// interface Matchers<R> {
11+
// toContainObject(value: object): CustomMatcherResult;
12+
// }
13+
// }
14+
}
15+
16+
// expect.extend({
17+
// toContainObject(received, argument) {
18+
19+
// const pass = this.equals(received,
20+
// expect.arrayContaining([
21+
// expect.objectContaining(argument)
22+
// ])
23+
// )
24+
25+
// if (pass) {
26+
// return {
27+
// message: () => (`expected ${this.utils.printReceived(received)} not to contain object ${this.utils.printExpected(argument)}`),
28+
// pass: true,
29+
// }
30+
// } else {
31+
// return {
32+
// message: () => (`expected ${this.utils.printReceived(received)} to contain object ${this.utils.printExpected(argument)}`),
33+
// pass: false,
34+
// }
35+
// }
36+
// }
37+
// })

jest.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
process.env.NODE_ENV = 'test'
2+
3+
module.exports = {
4+
coveragePathIgnorePatterns: ['/node_modules/', '/migrations/'],
5+
globalSetup: './src/__tests__/config/setup.ts',
6+
globalTeardown: './src/__tests__/config/teardown.ts',
7+
moduleNameMapper: {
8+
"^~(.*)$": "<rootDir>/src/$1"
9+
},
10+
preset: 'ts-jest',
11+
setupFilesAfterEnv: [
12+
'./src/__tests__/config/database.ts',
13+
],
14+
testEnvironment: 'node',
15+
testMatch: ['<rootDir>/**/*.test.ts'],
16+
}

nodemon.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"watch": [
3+
"src"
4+
],
5+
"ext": "ts",
6+
"ignore": [
7+
"__tests__/**/*.(spec|test).ts"
8+
],
9+
"quiet": true,
10+
"exec": "NODE_ENV=local ts-node -r tsconfig-paths/register src/index.ts"
11+
}

ormconfig.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ConnectionOptions } from 'typeorm'
2+
import config from './src/config'
3+
4+
const connectionOptions: ConnectionOptions = {
5+
cli: {
6+
entitiesDir: 'src/packages/database/models',
7+
migrationsDir: 'src/packages/database/migrations',
8+
},
9+
database: config.DB.NAME,
10+
entities: ['src/packages/database/models/*.ts'],
11+
host: config.DB.HOST,
12+
logging: false,
13+
migrations: ['src/packages/database/migrations/*.ts'],
14+
password: config.DB.PASSWORD,
15+
port: config.DB.PORT,
16+
synchronize: false,
17+
type: 'postgres',
18+
username: config.DB.USER,
19+
}
20+
21+
module.exports = connectionOptions

0 commit comments

Comments
 (0)