Skip to content

Commit facf204

Browse files
committed
adding api from react-ecommerce
1 parent 64ae77d commit facf204

61 files changed

Lines changed: 2405 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DATABASE_HOST=
2+
DATABASE_NAME=
3+
DATABASE_USER=
4+
DATABASE_PASSWORD=
5+
DATABASE_PORT=
6+
7+
SECRET=
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const tsconfig = require(`./tsconfig`);
2+
3+
module.exports = {
4+
parser: '@typescript-eslint/parser',
5+
parserOptions: {
6+
sourceType: 'module',
7+
tsconfigRootDir: __dirname,
8+
project: ["./tsconfig.json"],
9+
},
10+
plugins: ['@typescript-eslint/eslint-plugin'],
11+
extends: [
12+
'plugin:@typescript-eslint/recommended',
13+
`plugin:@typescript-eslint/eslint-recommended`,
14+
'plugin:prettier/recommended',
15+
],
16+
root: true,
17+
env: {
18+
node: true,
19+
jest: true,
20+
},
21+
ignorePatterns: ['.eslintrc.js'],
22+
rules: {
23+
'@typescript-eslint/interface-name-prefix': 'off',
24+
'@typescript-eslint/explicit-function-return-type': 'off',
25+
'@typescript-eslint/explicit-module-boundary-types': 'off',
26+
'@typescript-eslint/no-explicit-any': 'off',
27+
},
28+
settings: {
29+
'import/resolver': {
30+
typescript: {
31+
project: `.`,
32+
},
33+
},
34+
},
35+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
pnpm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# OS
15+
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json
36+
37+
.env.development
38+
.env.production
39+
.env
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"prettier/prettier": ["error",{
7+
"endOfLine": "auto"
8+
}
9+
]
10+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
TODO - Add table category
2+
TODO - Add table sub category
3+
TODO - Add table tags
4+
TODO - Create pipe to validate if the seller are employee to the correct store and if have the correct role
5+
6+
<p align="center">
7+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
8+
</p>
9+
10+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
11+
[circleci-url]: https://circleci.com/gh/nestjs/nest
12+
13+
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
14+
<p align="center">
15+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
16+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
17+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
18+
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
19+
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
20+
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
21+
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
22+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
23+
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
24+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
25+
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
26+
</p>
27+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
28+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
29+
30+
## Description
31+
32+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
33+
34+
## Installation
35+
36+
```bash
37+
$ npm install
38+
```
39+
40+
## Running the app
41+
42+
```bash
43+
# development
44+
$ npm run start
45+
46+
# watch mode
47+
$ npm run start:dev
48+
49+
# production mode
50+
$ npm run start:prod
51+
```
52+
53+
## Test
54+
55+
```bash
56+
# unit tests
57+
$ npm run test
58+
59+
# e2e tests
60+
$ npm run test:e2e
61+
62+
# test coverage
63+
$ npm run test:cov
64+
```
65+
66+
## Support
67+
68+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
69+
70+
## Stay in touch
71+
72+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
73+
- Website - [https://nestjs.com](https://nestjs.com/)
74+
- Twitter - [@nestframework](https://twitter.com/nestframework)
75+
76+
## License
77+
78+
Nest is [MIT licensed](LICENSE).
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Use postgres/example user/password credentials
2+
version: '3.1'
3+
4+
services:
5+
db:
6+
container_name: pg_database
7+
image: postgres
8+
restart: always
9+
ports:
10+
- '${DATABASE_PORT}:${DATABASE_PORT}'
11+
hostname: '${DATABASE_HOST}'
12+
environment:
13+
POSTGRES_USER: '${DATABASE_USER}'
14+
POSTGRES_PASSWORD: '${DATABASE_PASSWORD}'
15+
POSTGRES_DB: '${DATABASE_NAME}'
16+
pgadmin:
17+
container_name: pgadmin4_container
18+
image: dpage/pgadmin4
19+
restart: always
20+
environment:
21+
PGADMIN_DEFAULT_EMAIL: admin@admin.com
22+
PGADMIN_DEFAULT_PASSWORD: root
23+
ports:
24+
- "5050:80"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"collection": "@nestjs/schematics",
3+
"sourceRoot": "src",
4+
"compilerOptions": {
5+
"plugins": ["@nestjs/graphql"]
6+
}
7+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "@react-shop/server",
3+
"version": "0.0.1",
4+
"description": "",
5+
"author": "",
6+
"private": true,
7+
"license": "UNLICENSED",
8+
"scripts": {
9+
"prebuild": "rimraf dist",
10+
"build": "nest build",
11+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
12+
"start": "nest start",
13+
"dev": "nest start --watch",
14+
"start:debug": "nest start --debug --watch",
15+
"start:prod": "node dist/main",
16+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
17+
"test": "jest",
18+
"test:watch": "jest --watch",
19+
"test:cov": "jest --coverage",
20+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21+
"test:e2e": "jest --config ./test/jest-e2e.json"
22+
},
23+
"dependencies": {
24+
"@nestjs/common": "^8.0.0",
25+
"@nestjs/config": "^1.0.1",
26+
"@nestjs/core": "^8.0.0",
27+
"@nestjs/graphql": "^9.0.2",
28+
"@nestjs/jwt": "^8.0.0",
29+
"@nestjs/passport": "^8.0.1",
30+
"@nestjs/platform-express": "^8.0.0",
31+
"@nestjs/swagger": "^5.0.9",
32+
"@nestjs/typeorm": "^8.0.2",
33+
"apollo-server-express": "^3.3.0",
34+
"bcrypt": "^5.0.1",
35+
"class-transformer": "^0.4.0",
36+
"class-validator": "^0.13.1",
37+
"graphql": "^15.5.1",
38+
"passport": "^0.4.1",
39+
"passport-jwt": "^4.0.0",
40+
41+
"pg": "^8.7.1",
42+
"reflect-metadata": "^0.1.13",
43+
"rimraf": "^3.0.2",
44+
"rxjs": "^7.2.0",
45+
"swagger-ui-express": "^4.1.6",
46+
"typeorm": "^0.2.37"
47+
},
48+
"devDependencies": {
49+
"@nestjs/cli": "^8.0.0",
50+
"@nestjs/schematics": "^8.0.0",
51+
"@nestjs/testing": "^8.0.0",
52+
"@types/bcrypt": "^5.0.0",
53+
"@types/express": "^4.17.13",
54+
"@types/jest": "^26.0.24",
55+
"@types/node": "^16.0.0",
56+
"@types/passport-jwt": "^3.0.6",
57+
"@types/supertest": "^2.0.11",
58+
"@typescript-eslint/eslint-plugin": "^4.28.2",
59+
"@typescript-eslint/parser": "^4.28.2",
60+
"eslint": "^7.30.0",
61+
"eslint-config-prettier": "^8.3.0",
62+
"eslint-plugin-prettier": "^3.4.0",
63+
"jest": "27.0.6",
64+
"prettier": "^2.3.2",
65+
"supertest": "^6.1.3",
66+
"ts-jest": "^27.0.3",
67+
"ts-loader": "^9.2.3",
68+
"ts-node": "^10.0.0",
69+
"tsconfig-paths": "^3.10.1",
70+
"typescript": "^4.3.5"
71+
},
72+
"jest": {
73+
"moduleFileExtensions": [
74+
"js",
75+
"json",
76+
"ts"
77+
],
78+
"rootDir": "src",
79+
"testRegex": ".*\\.spec\\.ts$",
80+
"transform": {
81+
"^.+\\.(t|j)s$": "ts-jest"
82+
},
83+
"collectCoverageFrom": [
84+
"**/*.(t|j)s"
85+
],
86+
"coverageDirectory": "../coverage",
87+
"testEnvironment": "node"
88+
}
89+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Get, Controller } from '@nestjs/common';
2+
3+
@Controller()
4+
export class AppController {
5+
@Get()
6+
root(): string {
7+
return 'Health check ok!';
8+
}
9+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Module } from '@nestjs/common';
2+
import { GraphQLModule } from '@nestjs/graphql';
3+
import { TypeOrmModule } from '@nestjs/typeorm';
4+
import { ConfigModule } from '@nestjs/config';
5+
import { join } from 'path';
6+
7+
import { UserModule } from '@user/user.module';
8+
import { AuthModule } from '@auth/auth.module';
9+
import { ProductModule } from '@product/product.module';
10+
import { StoreModule } from '@store/store.module';
11+
import { AttributeModule } from '@attribute/attribute.module';
12+
import { CategoryModule } from '@category/category.module';
13+
14+
import { AppController } from './app.controller';
15+
16+
@Module({
17+
imports: [
18+
ConfigModule.forRoot({
19+
envFilePath: ['.env.development', '.env.production'],
20+
}),
21+
GraphQLModule.forRoot({
22+
autoSchemaFile: join(process.cwd(), 'src/graphql/schemas/schema.gql'),
23+
context: ({ req }) => ({ req }),
24+
}),
25+
TypeOrmModule.forRoot({
26+
type: 'postgres',
27+
host: process.env.DATABASE_HOST,
28+
port: (process.env.DATABASE_PORT as unknown) as number,
29+
username: process.env.DATABASE_USER,
30+
password: process.env.DATABASE_PASSWORD,
31+
database: process.env.DATABASE_NAME,
32+
autoLoadEntities: true,
33+
synchronize: true,
34+
}),
35+
UserModule,
36+
AuthModule,
37+
ProductModule,
38+
AttributeModule,
39+
StoreModule,
40+
CategoryModule,
41+
],
42+
controllers: [AppController],
43+
})
44+
export class AppModule {}

0 commit comments

Comments
 (0)