Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9b0dc3c
:wrench: chore: add editorconfig support
gajaguar Jul 22, 2021
2e3be5f
:lock: fix(deps-dev): bump nodemon from `1.19.4` to `2.0.12`
gajaguar Jul 22, 2021
6db85d9
:arrow_up: chore(deps-dev): bump mongodb from `3.6.6` to `4.0.1`
gajaguar Jul 22, 2021
2dd10ad
:arrow_up: chore(deps-dev): bump dotenv from `8.2.0` to `10.0.0`
gajaguar Jul 22, 2021
7e46a4d
:heavy_plus_sign: chore(deps-dev): add `@babel/cli`
gajaguar Jul 24, 2021
5637119
:heavy_plus_sign: chore(deps-dev): add `@babel/core`
gajaguar Jul 24, 2021
398c287
:heavy_plus_sign: chore(deps-dev): add `@babel/eslint-parser`
gajaguar Jul 24, 2021
6d4f1e3
:heavy_plus_sign: chore(deps-dev): add `@babel/preset-env`
gajaguar Jul 24, 2021
adb8ff5
:heavy_plus_sign: chore(deps-dev): add `@babel/preset-typescript`
gajaguar Jul 24, 2021
a01061c
:heavy_plus_sign: chore(deps-dev): add `@tsconfig/node14`
gajaguar Jul 24, 2021
bc5e60b
:heavy_plus_sign: chore(deps-dev): add `@types/express`
gajaguar Jul 24, 2021
cc695f9
:heavy_plus_sign: chore(deps-dev): add `@types/node`
gajaguar Jul 24, 2021
1108616
:heavy_plus_sign: chore(deps-dev): add `@typescript-eslint/eslint-plu…
gajaguar Jul 24, 2021
a98145b
:heavy_plus_sign: chore(deps-dev): add `@typescript-eslint/parser`
gajaguar Jul 24, 2021
b21cdc2
:heavy_plus_sign: chore(deps-dev): add `eslint`
gajaguar Jul 24, 2021
e9ea305
:heavy_plus_sign: chore(deps-dev): add `eslint-config-prettier`
gajaguar Jul 24, 2021
03ef918
:heavy_plus_sign: chore(deps-dev): add `eslint-plugin-prettier`
gajaguar Jul 24, 2021
7325229
:heavy_plus_sign: chore(deps-dev): add `eslint-plugin-tsdoc`
gajaguar Jul 24, 2021
c50f354
:heavy_plus_sign: chore(deps-dev): add `prettier`
gajaguar Jul 24, 2021
cb2e93e
:heavy_plus_sign: chore(deps-dev): add `ts-node`
gajaguar Jul 24, 2021
86b7674
:heavy_plus_sign: chore(deps-dev): add `tsconfig-paths`
gajaguar Jul 24, 2021
492adfa
:heavy_plus_sign: chore(deps-dev): add `typescript`
gajaguar Jul 24, 2021
035635c
:wrench: chore(compiler): configure babel
gajaguar Jul 24, 2021
36391d5
:wrench: chore(linter): configure eslint
gajaguar Jul 24, 2021
c3ead52
:wrench: chore(linter): configure prettier
gajaguar Jul 24, 2021
3bd4b1b
:wrench: chore(compiler): configure typescript
gajaguar Jul 24, 2021
24a05d0
:hammer: chore(scripts): add and modify multiple scripts
gajaguar Jul 24, 2021
ffeef89
:truck: chore: change extension of entire `src` files
gajaguar Jul 24, 2021
172f10a
:recycle: refactor(config): convert into typescript format
gajaguar Jul 24, 2021
b88245c
:heavy_plus_sign: chore(deps-dev): add `@types/cors`
gajaguar Jul 24, 2021
dbd9141
:recycle: refactor(src): convert into typescript format
gajaguar Jul 24, 2021
9b0704e
:wrench: chore(compiler): add `@types/cors` to `tsconfig.json`
gajaguar Jul 24, 2021
54fad8c
:rotating_light: style(tests): disable eslint
gajaguar Jul 24, 2021
65dab2d
:rotating_light: style: fix some lint warnings
gajaguar Jul 24, 2021
462ad80
:recycle: refactor(config): improve config variables.
gajaguar Jul 24, 2021
d852b45
:bulb: chore(src): add doc block to `createApp` function
gajaguar Jul 24, 2021
3a1ca8f
:art: chore(src): remove error catcher and add init advice
gajaguar Jul 24, 2021
edfa024
:recycle: refactor(container): compose file use environment variables
gajaguar Jul 22, 2021
df67965
:construction: chore(routes): add basic API router for `products`
gajaguar Jul 24, 2021
9ecdae0
:construction: chore(routes): add basic API router for `categories`
gajaguar Jul 24, 2021
5cf08a1
:sparkles: chore(utils): add function that generates a connection string
gajaguar Jul 24, 2021
c791a11
:sparkles: chore(services): create a store service that use MongoDB
gajaguar Jul 24, 2021
d55ab30
:construction: chore(services): add a `product` resource service
gajaguar Jul 25, 2021
291d3e9
:sparkles: chore(network): implement a response standard method
gajaguar Jul 25, 2021
96d6135
:construction: chore(routes): implement `products` service in router
gajaguar Jul 25, 2021
82c1417
:adhesive_bandage: fix(services): change the type of the `id` parameters
gajaguar Jul 25, 2021
f5320c5
:rotating_light: style(types): delete blank line after doc block
gajaguar Jul 25, 2021
da17054
:truck: chore(utils): change import path to relative
gajaguar Jul 25, 2021
d36c983
:see_no_evil: chore(gitignore): add `lib` directory
gajaguar Jul 25, 2021
6f690ef
:adhesive_bandage: fix(container): update the environment variables name
gajaguar Jul 25, 2021
fe303a1
:arrow_up: chore(deps-dev): bump `@typescript-eslint/parser` from `4.…
gajaguar Jul 27, 2021
6385c42
:arrow_up: chore(deps-dev): bump `@types/node` from `16.4.1` to `16.4.3`
gajaguar Jul 27, 2021
28a13fb
:arrow_up: chore(deps-dev): bump `@typescript-eslitnt/eslint-plugin` …
gajaguar Jul 27, 2021
e3155e8
:arrow_up: chore(deps-dev): bump `supertest` from `6.1.3` to `6.1.4`
gajaguar Jul 27, 2021
d51dc9c
:art: chore(config): change the way of re exports
gajaguar Jul 27, 2021
5f46bab
:construction: chore(services): add a `categores` resource service
gajaguar Jul 27, 2021
5e4c09b
:construction: chore(routes): implement `categories` service in router
gajaguar Jul 27, 2021
f05a78b
:art: chore(utils): create error handler middlewares
gajaguar Jul 27, 2021
1e52dfe
:bulb: chore(utils): remove middlewares eslint disables
gajaguar Jul 27, 2021
1e361fb
:sparkles: chore(src): implement errors handlers middlewares
gajaguar Jul 27, 2021
1804081
:speech_balloon: chore(network): wrap `err` into `error` in response
gajaguar Jul 27, 2021
6935820
:pencil2: fix(env): change variable from `DB_DB_NAME` to `DB_NAME`
gajaguar Jul 27, 2021
477742a
:art: chore(utils): add return type to errors handler middlewares
gajaguar Jul 27, 2021
2c3f70f
:sparkles: chore(services): create a base resource service class
gajaguar Jul 27, 2021
bdb17c8
:recycle: refactor(services): implement base service in current resou…
gajaguar Jul 27, 2021
0d21613
:sparkles: chore(types): add interface to store services
gajaguar Jul 27, 2021
2573b57
:art: chore(services): implement interface in mongodb store service
gajaguar Jul 27, 2021
cfce2f8
:sparkles: chore(types): add interface to resource service
gajaguar Jul 27, 2021
8402499
:adhesive_bandage: fix(types): remove parameter in `StoreService` `re…
gajaguar Jul 27, 2021
3f38fca
:adhesive_bandage: fix(types): add resource service re export to index
gajaguar Jul 27, 2021
342842c
:sparkles: chore(routes): add an routes builder
gajaguar Jul 27, 2021
cd9eff4
:recycle: refactor(routes): implement routes builder in resources
gajaguar Jul 27, 2021
6fdb7e2
:heavy_plus_sign: chore(deps-dev): add `joi`
gajaguar Jul 28, 2021
ac86776
:truck: chore(middlewares): move from `utils` to `network`
gajaguar Jul 28, 2021
66f18d0
:truck: chore(utils): move base resource service from `services` to `…
gajaguar Jul 28, 2021
972baf0
:art: chore(utils): add types to base resource service class
gajaguar Jul 28, 2021
d1071ea
:recycle: refactor(routes): improve the routes builder
gajaguar Jul 28, 2021
8157a86
:zap: refactor(utils): improve the route builder
gajaguar Jul 28, 2021
f57f9f0
:zap: refactor(routes): implement the new base router class
gajaguar Jul 28, 2021
378f8c2
:sparkles: chore(network): add validation handler middleware
gajaguar Jul 29, 2021
89c46ef
:sparkles: chore(models): add models
gajaguar Jul 29, 2021
3437728
:construction: chore(utils): prepare base router to schema validations
gajaguar Jul 29, 2021
80e7baf
:construction: chore(routes): implement partial validation
gajaguar Jul 29, 2021
2e129f9
:truck: chore(utils): rearrange base router
gajaguar Jul 30, 2021
e2ce74d
:zap: chore(network): organize imports in errors handler
gajaguar Jul 30, 2021
e16c794
:bug: fix(network): repair validation handler when `schema` is `undef…
gajaguar Jul 30, 2021
3cc2ece
:art: chore(types): improve model interface
gajaguar Jul 30, 2021
0e0a6d9
:recycle: refactor(models): improve category model
gajaguar Jul 30, 2021
58934a7
:recycle: refactor(models): improve product model
gajaguar Jul 31, 2021
964dcc0
:bulb: chore(utils): improve doc block of `getConnectionString`
gajaguar Jul 31, 2021
e9f2607
:bulb: chore(src): improve doc block of `createApp`
gajaguar Jul 31, 2021
f16f544
:arrow_up: chore(deps-dev): bump `@types/node` from `16.4.3` to `16.4.8`
gajaguar Jul 31, 2021
fd8df2a
:arrow_up: chore(deps-dev): bump `eslint` from `7.31.0` to `7.32.0`
gajaguar Jul 31, 2021
9d1ce25
:heavy_plus_sign: chore(deps-dev): add `@types/jest`
gajaguar Jul 31, 2021
3ef16a7
:heavy_plus_sign: chore(deps-dev): add `babel-jest`
gajaguar Jul 31, 2021
bb84a97
:arrow_up: chore(deps-dev): bump `jest` from `26.6.3` to `27.0.6`
gajaguar Jul 31, 2021
59ed6a9
:heavy_plus_sign: chore(deps-dev): add `ts-jest`
gajaguar Jul 31, 2021
ac34f1c
:wrench: chore(compiler): configure typescript to use jest types
gajaguar Jul 31, 2021
1f4c725
:wrench: chore(test): add jest configuration file
gajaguar Jul 31, 2021
dc1a5bf
:heavy_plus_sign: chore(deps-dev): add `@types/supertest`
gajaguar Jul 31, 2021
ca3837e
:wrench: chore(compiler): configure typescript to use supertest types
gajaguar Jul 31, 2021
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
17 changes: 17 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
},
"@babel/preset-typescript"
]
]
}
}
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
20 changes: 13 additions & 7 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
PORT=3000
MONGO_USER=
MONGO_PASSWORD=
MONGO_HOST=
MONGO_DB_NAME=
MONGO_PORT=
MONGO_CONNECTION=
# Application
APP_NAME=backend-node-evaluation
APP_HOST=127.0.0.1
APP_PORT=3000

# Database
DB_DRIVER=mongodb
DB_USER=root
DB_PASSWORD=secret
DB_HOST=127.0.0.1
DB_NAME=backendNodeEvaluation
DB_PORT=27017
DB_PROTOCOL=mongodb
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: {
browser: false,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
extends: [
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: ['eslint-plugin-tsdoc'],
// add your custom rules here
rules: {
'tsdoc/syntax': 'warn',
},
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ bower_components
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Production code
lib

# Dependency directories
node_modules/
jspm_packages/
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
mongo:
image: mongo:4.4
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
MONGO_INITDB_ROOT_USERNAME: "${DB_USER}"
MONGO_INITDB_ROOT_PASSWORD: "${DB_PASSWORD}"
ports:
- 27017:27017
- "${DB_PORT}:${DB_PORT}"
16 changes: 9 additions & 7 deletions e2e/categories.e2e.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable */

const request = require("supertest");
const { MongoClient, ObjectId } = require("mongodb");

const { config } = require("../src/config");
const { database } = require("../src/config")
const createApp = require("../src/app");

const USER = encodeURIComponent(config.dbUser);
const PASSWORD = encodeURIComponent(config.dbPassword);
const DB_NAME = config.dbName;
const USER = encodeURIComponent(database.user);
const PASSWORD = encodeURIComponent(database.password);
const DB_NAME = database.name;

const MONGO_URI = `${config.dbConnection}://${USER}:${PASSWORD}@${config.dbHost}:${config.dbPort}?retryWrites=true&w=majority`;
const MONGO_URI = `${database.protocol}://${USER}:${PASSWORD}@${database.host}:${database.port}?retryWrites=true&w=majority`;
const collection = 'categories';

describe("Tests to categories", () => {
Expand Down Expand Up @@ -109,7 +111,7 @@ describe("Tests to categories", () => {
});

describe("GET /api/categories/{id}/products", () => {

it("should return a list products by category", async (done) => {
const categories = await database.collection(collection).find().toArray();
expect(categories.length > 0).toBe(true);
Expand Down Expand Up @@ -149,5 +151,5 @@ describe("Tests to categories", () => {
});
});


});
2 changes: 1 addition & 1 deletion e2e/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e.js$"
}
}
14 changes: 8 additions & 6 deletions e2e/product.e2e.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable */

const request = require("supertest");
const { MongoClient, ObjectId } = require("mongodb");

const { config } = require("../src/config");
const { database } = require("../src/config")
const createApp = require("./../src/app");

const USER = encodeURIComponent(config.dbUser);
const PASSWORD = encodeURIComponent(config.dbPassword);
const DB_NAME = config.dbName;
const USER = encodeURIComponent(database.user);
const PASSWORD = encodeURIComponent(database.password);
const DB_NAME = database.name;

const MONGO_URI = `${config.dbConnection}://${USER}:${PASSWORD}@${config.dbHost}:${config.dbPort}?retryWrites=true&w=majority`;
const MONGO_URI = `${database.protocol}://${USER}:${PASSWORD}@${database.dbHost}:${database.dbPort}?retryWrites=true&w=majority`;
const collection = 'products';

describe("Tests to products", () => {
Expand Down Expand Up @@ -124,5 +126,5 @@ describe("Tests to products", () => {
});
});


});
13 changes: 13 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/$1',
},
moduleFileExtensions: ['ts', 'js', 'json'],
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
},
collectCoverage: true,
collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
testEnvironment: 'jsdom',
}
Loading