bardd commited on
Commit
2207a90
·
verified ·
1 Parent(s): 8c08ff8

fixed login

Browse files
README.md CHANGED
@@ -1,10 +1,85 @@
1
- ---
2
- license: mit
3
- title: node_front
4
- sdk: docker
5
- emoji: 🚀
6
- colorFrom: yellow
7
- colorTo: red
8
- pinned: true
9
- short_description: test node back end
10
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3
+ </p>
4
+
5
+ [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6
+ [circleci-url]: https://circleci.com/gh/nestjs/nest
7
+
8
+ <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>
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13
+ <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>
14
+ <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>
15
+ <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
16
+ <a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
17
+ <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
18
+ <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
19
+ <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>
20
+ <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
21
+ </p>
22
+ <!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
23
+ [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
24
+
25
+ ## Description
26
+
27
+ [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
28
+
29
+ ## Project setup
30
+
31
+ ```bash
32
+ $ npm install
33
+ ```
34
+
35
+ ## Compile and run the project
36
+
37
+ ```bash
38
+ # development
39
+ $ npm run start
40
+
41
+ # watch mode
42
+ $ npm run start:dev
43
+
44
+ # production mode
45
+ $ npm run start:prod
46
+ ```
47
+
48
+ ## Run tests
49
+
50
+ ```bash
51
+ # unit tests
52
+ $ npm run test
53
+
54
+ # e2e tests
55
+ $ npm run test:e2e
56
+
57
+ # test coverage
58
+ $ npm run test:cov
59
+ ```
60
+
61
+ ## Resources
62
+
63
+ Check out a few resources that may come in handy when working with NestJS:
64
+
65
+ - Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
66
+ - For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
67
+ - To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
68
+ - Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
69
+ - Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
70
+ - To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
71
+ - Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
72
+
73
+ ## Support
74
+
75
+ 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).
76
+
77
+ ## Stay in touch
78
+
79
+ - Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
80
+ - Website - [https://nestjs.com](https://nestjs.com/)
81
+ - Twitter - [@nestframework](https://twitter.com/nestframework)
82
+
83
+ ## License
84
+
85
+ Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
package.json CHANGED
@@ -1,78 +1,83 @@
1
- {
2
- "name": "property",
3
- "version": "0.0.1",
4
- "description": "",
5
- "author": "",
6
- "private": true,
7
- "license": "UNLICENSED",
8
- "scripts": {
9
- "build": "nest build",
10
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11
- "start": "node dist/main",
12
- "start:dev": "nest start --watch",
13
- "start:debug": "nest start --debug --watch",
14
- "start:prod": "node dist/main",
15
- "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
16
- "test": "jest",
17
- "test:watch": "jest --watch",
18
- "@nestjs/common": "^10.0.0",
19
- "@nestjs/core": "^10.0.0",
20
- "@nestjs/jwt": "^10.2.0",
21
- "@nestjs/passport": "^10.0.3",
22
- "@nestjs/platform-express": "^10.0.0",
23
- "bcrypt": "^5.1.1",
24
- "body-parser": "^1.20.2",
25
- "class-transformer": "^0.5.1",
26
- "class-validator": "^0.14.1",
27
- "cors": "^2.8.5",
28
- "i18n-ts": "^1.0.5",
29
- "jwt-decode": "^4.0.0",
30
- "mongoose": "^8.6.0",
31
- "passport-custom": "^1.1.1",
32
- "passport-jwt": "^4.0.1",
33
- "passport-local": "^1.0.0",
34
- "reflect-metadata": "^0.2.0",
35
- "rxjs": "^7.8.1",
36
- "uuid": "^10.0.0"
37
- },
38
- "devDependencies": {
39
- "@nestjs/cli": "^10.0.0",
40
- "@nestjs/schematics": "^10.0.0",
41
- "@nestjs/testing": "^10.0.0",
42
- "@types/express": "^4.17.17",
43
- "@types/jest": "^29.5.2",
44
- "@types/node": "^20.3.1",
45
- "@types/supertest": "^6.0.0",
46
- "@typescript-eslint/eslint-plugin": "^8.0.0",
47
- "@typescript-eslint/parser": "^8.0.0",
48
- "eslint": "^8.42.0",
49
- "eslint-config-prettier": "^9.0.0",
50
- "eslint-plugin-prettier": "^5.0.0",
51
- "jest": "^29.5.0",
52
- "prettier": "^3.0.0",
53
- "source-map-support": "^0.5.21",
54
- "supertest": "^7.0.0",
55
- "ts-jest": "^29.1.0",
56
- "ts-loader": "^9.4.3",
57
- "ts-node": "^10.9.1",
58
- "tsconfig-paths": "^4.2.0",
59
- "typescript": "^5.1.3"
60
- },
61
- "jest": {
62
- "moduleFileExtensions": [
63
- "js",
64
- "json",
65
- "ts"
66
- ],
67
- "rootDir": "src",
68
- "testRegex": ".*\\.spec\\.ts$",
69
- "transform": {
70
- "^.+\\.(t|j)s$": "ts-jest"
71
- },
72
- "collectCoverageFrom": [
73
- "**/*.(t|j)s"
74
- ],
75
- "coverageDirectory": "../coverage",
76
- "testEnvironment": "node"
77
- }
78
- }
 
 
 
 
 
 
1
+ {
2
+ "name": "property",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "author": "",
6
+ "private": true,
7
+ "license": "UNLICENSED",
8
+ "scripts": {
9
+ "build": "nest build",
10
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11
+ "start": "nest start",
12
+ "start:dev": "nest start --watch",
13
+ "start:debug": "nest start --debug --watch",
14
+ "start:prod": "node dist/main.js",
15
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
16
+ "test": "jest",
17
+ "test:watch": "jest --watch",
18
+ "test:cov": "jest --coverage",
19
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
20
+ "test:e2e": "jest --config ./test/jest-e2e.json"
21
+ },
22
+ "dependencies": {
23
+ "@nestjs/common": "^10.0.0",
24
+ "@nestjs/core": "^10.0.0",
25
+ "@nestjs/jwt": "^10.2.0",
26
+ "@nestjs/passport": "^10.0.3",
27
+ "@nestjs/platform-express": "^10.0.0",
28
+ "bcrypt": "^5.1.1",
29
+ "body-parser": "^1.20.2",
30
+ "class-transformer": "^0.5.1",
31
+ "class-validator": "^0.14.1",
32
+ "cors": "^2.8.5",
33
+ "i18n-ts": "^1.0.5",
34
+ "jwt-decode": "^4.0.0",
35
+ "mongoose": "^8.6.0",
36
+ "passport-custom": "^1.1.1",
37
+ "passport-jwt": "^4.0.1",
38
+ "passport-local": "^1.0.0",
39
+ "reflect-metadata": "^0.2.0",
40
+ "rxjs": "^7.8.1",
41
+ "uuid": "^10.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@nestjs/cli": "^10.0.0",
45
+ "@nestjs/schematics": "^10.0.0",
46
+ "@nestjs/testing": "^10.0.0",
47
+ "@types/express": "^4.17.17",
48
+ "@types/jest": "^29.5.2",
49
+ "@types/node": "^20.3.1",
50
+ "@types/supertest": "^6.0.0",
51
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
52
+ "@typescript-eslint/parser": "^8.0.0",
53
+ "eslint": "^8.42.0",
54
+ "eslint-config-prettier": "^9.0.0",
55
+ "eslint-plugin-prettier": "^5.0.0",
56
+ "jest": "^29.5.0",
57
+ "prettier": "^3.0.0",
58
+ "source-map-support": "^0.5.21",
59
+ "supertest": "^7.0.0",
60
+ "ts-jest": "^29.1.0",
61
+ "ts-loader": "^9.4.3",
62
+ "ts-node": "^10.9.1",
63
+ "tsconfig-paths": "^4.2.0",
64
+ "typescript": "^5.1.3"
65
+ },
66
+ "jest": {
67
+ "moduleFileExtensions": [
68
+ "js",
69
+ "json",
70
+ "ts"
71
+ ],
72
+ "rootDir": "src",
73
+ "testRegex": ".*\\.spec\\.ts$",
74
+ "transform": {
75
+ "^.+\\.(t|j)s$": "ts-jest"
76
+ },
77
+ "collectCoverageFrom": [
78
+ "**/*.(t|j)s"
79
+ ],
80
+ "coverageDirectory": "../coverage",
81
+ "testEnvironment": "node"
82
+ }
83
+ }
src/main.ts CHANGED
@@ -19,9 +19,6 @@ async function bootstrap() {
19
  app.use(bodyParser.urlencoded({ extended: true }));
20
  app.use(bodyParser.json());
21
 
22
- // Use the PORT environment variable or default to 8080
23
- const port = process.env.PORT || 7860;
24
-
25
- await app.listen(port);
26
  }
27
  bootstrap();
 
19
  app.use(bodyParser.urlencoded({ extended: true }));
20
  app.use(bodyParser.json());
21
 
22
+ await app.listen(8080);
 
 
 
23
  }
24
  bootstrap();
src/modules/activity/activity.controller.ts CHANGED
@@ -26,14 +26,14 @@ export class ActivityController extends CommonServices {
26
  }
27
 
28
  @Post('create')
29
- // @UseGuards(JwtAuthGuard)
30
  async createActivity(@Body() body: any, @Res() res: Response, @Req() req) {
31
  try {
32
- // const payload = {
33
- // ...body,
34
- // userId: req.user.userId,
35
- // };
36
- const activity = await this.activityService.sharedCreate(body);
37
 
38
  // update views
39
  if (body.action == 'view')
 
26
  }
27
 
28
  @Post('create')
29
+ @UseGuards(JwtAuthGuard)
30
  async createActivity(@Body() body: any, @Res() res: Response, @Req() req) {
31
  try {
32
+ const payload = {
33
+ ...body,
34
+ userId: req.user.userId,
35
+ };
36
+ const activity = await this.activityService.sharedCreate(payload);
37
 
38
  // update views
39
  if (body.action == 'view')
src/modules/activity/activity.schema.ts CHANGED
@@ -4,7 +4,7 @@ import { IUserDocument } from '../user/user.schema';
4
  import { IPropertyDocument } from '../property/property.schema';
5
 
6
  export interface IUserActivityDocument extends Document {
7
- // userId: IUserDocument;
8
  propertyId: IPropertyDocument;
9
  action: string; // E.g., 'click', 'view', 'time_spent'
10
  sessionId: string;
@@ -16,11 +16,11 @@ export interface IUserActivityDocument extends Document {
16
 
17
  const UserActivitySchema = new mongoose.Schema<IUserActivityDocument>(
18
  {
19
- // userId: {
20
- // type: mongoose.Schema.Types.ObjectId,
21
- // ref: 'User',
22
- // required: true,
23
- // },
24
  propertyId: {
25
  type: mongoose.Schema.Types.ObjectId,
26
  ref: 'propertie',
 
4
  import { IPropertyDocument } from '../property/property.schema';
5
 
6
  export interface IUserActivityDocument extends Document {
7
+ userId: IUserDocument;
8
  propertyId: IPropertyDocument;
9
  action: string; // E.g., 'click', 'view', 'time_spent'
10
  sessionId: string;
 
16
 
17
  const UserActivitySchema = new mongoose.Schema<IUserActivityDocument>(
18
  {
19
+ userId: {
20
+ type: mongoose.Schema.Types.ObjectId,
21
+ ref: 'User',
22
+ // required: true,
23
+ },
24
  propertyId: {
25
  type: mongoose.Schema.Types.ObjectId,
26
  ref: 'propertie',