Skip to content

Commit 3a3b942

Browse files
committed
feat: adding logged admin
1 parent 45de7c4 commit 3a3b942

24 files changed

+826
-55
lines changed

example-app/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"dependencies": {
2121
"@nestjs/common": "^6.7.2",
2222
"@nestjs/core": "^6.7.2",
23+
"@nestjs/mongoose": "^7.0.2",
2324
"@nestjs/platform-express": "^6.7.2",
25+
"mongoose": "^5.9.27",
2426
"reflect-metadata": "^0.1.13",
2527
"rimraf": "^3.0.0",
2628
"rxjs": "^6.5.3"
@@ -34,6 +36,11 @@
3436
"@types/node": "^12.7.5",
3537
"@types/supertest": "^2.0.8",
3638
"cypress": "^4.11.0",
39+
"eslint": "^7.1.0",
40+
"eslint-plugin-import": "^2.20.2",
41+
"eslint-plugin-jest": "^23.13.1",
42+
"eslint-plugin-jsdoc": "^25.4.2",
43+
"eslint-plugin-prefer-arrow": "^1.2.1",
3744
"jest": "^24.9.0",
3845
"prettier": "^1.18.2",
3946
"supertest": "^4.0.2",
@@ -42,12 +49,7 @@
4249
"ts-node": "^8.4.1",
4350
"tsc-watch": "^2.4.0",
4451
"tsconfig-paths": "^3.9.0",
45-
"typescript": "^3.6.3",
46-
"eslint": "^7.1.0",
47-
"eslint-plugin-import": "^2.20.2",
48-
"eslint-plugin-jest": "^23.13.1",
49-
"eslint-plugin-jsdoc": "^25.4.2",
50-
"eslint-plugin-prefer-arrow": "^1.2.1"
52+
"typescript": "^3.6.3"
5153
},
5254
"jest": {
5355
"moduleFileExtensions": [

example-app/src/app.module.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import { AppController } from './app.controller';
66
import { AppService } from './app.service';
77

88
@Module({
9-
imports: [AdminModule.createAdminModule()],
9+
imports: [AdminModule.createAdminModule({
10+
adminBroOptions: {
11+
rootPath: '/admin',
12+
},
13+
// auth: {
14+
// authenticate: async () => new Promise(() => ({ email: 'mordeczka' })),
15+
// cookieName: 'test',
16+
// cookiePassword: 'testPass',
17+
// },
18+
})],
1019
controllers: [AppController],
1120
providers: [AppService],
1221
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const AdminSchema = new Schema({
6+
email: {
7+
type: String,
8+
required: true,
9+
},
10+
password: {
11+
type: String,
12+
required: true,
13+
},
14+
})
15+
16+
const Admin = mongoose.model('Admin', AdminSchema)
17+
18+
module.exports = Admin
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const ArticleSchema = new Schema({
6+
title: {
7+
type: String,
8+
required: true,
9+
},
10+
content: {
11+
type: String,
12+
required: true,
13+
},
14+
photo: {
15+
type: String,
16+
required: true,
17+
},
18+
author: {
19+
type: Schema.Types.ObjectId,
20+
ref: 'User',
21+
},
22+
published: Boolean,
23+
}, { timestamps: true })
24+
25+
const Article = mongoose.model('Article', ArticleSchema)
26+
27+
module.exports = Article
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const BlogPostSchema = new Schema({
6+
title: {
7+
type: String,
8+
required: true,
9+
},
10+
content: {
11+
type: String,
12+
required: true,
13+
},
14+
category: {
15+
type: Schema.Types.ObjectId,
16+
ref: 'Category',
17+
},
18+
createdBy: String,
19+
}, { timestamps: true })
20+
21+
const BlogPost = mongoose.model('BlogPost', BlogPostSchema)
22+
23+
module.exports = BlogPost
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const CategorySchema = new Schema({
6+
title: {
7+
type: String,
8+
required: true,
9+
},
10+
createdAt: Date,
11+
owner: String,
12+
nested: {
13+
field: String,
14+
value: Number,
15+
},
16+
}, { timestamps: true })
17+
18+
const Category = mongoose.model('Category', CategorySchema)
19+
20+
module.exports = Category
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const CommentSchema = new Schema({
6+
content: {
7+
type: String,
8+
required: true,
9+
},
10+
flagged: Boolean,
11+
category: {
12+
type: Schema.Types.ObjectId,
13+
ref: 'Category',
14+
},
15+
}, { timestamps: true })
16+
17+
const Comment = mongoose.model('Comment', CommentSchema)
18+
19+
module.exports = Comment
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const Nested = new Schema({
6+
extremelyNested: String,
7+
}, { _id: false })
8+
9+
const ImageVariant = new mongoose.Schema({
10+
imageURL: String,
11+
isApproved: Boolean,
12+
dateCreated: {
13+
type: Date,
14+
default: Date.now,
15+
},
16+
isDeleted: Boolean
17+
}, { _id: false });
18+
19+
const Item = new mongoose.Schema({
20+
imageVariants: [ImageVariant],
21+
}, { _id: false })
22+
23+
const NestedSchema = new Schema({
24+
age: {
25+
type: Number,
26+
required: true,
27+
},
28+
height: Number,
29+
placeOfBirth: String,
30+
nested: Nested,
31+
}, { _id: false })
32+
33+
const ParentSchema = new Schema({
34+
name: String,
35+
surname: String,
36+
}, { _id: false })
37+
38+
const ComplicatedSchema = new Schema({
39+
name: String,
40+
stringArray: {
41+
type: [String],
42+
required: true,
43+
},
44+
authors: [{
45+
type: Schema.Types.ObjectId,
46+
ref: 'Category',
47+
}],
48+
nestedDetails: {
49+
type: NestedSchema
50+
},
51+
parents: [ParentSchema],
52+
Item : [Item],
53+
}, { timestamps: true })
54+
55+
const Complicated = mongoose.model('Complicated', ComplicatedSchema)
56+
57+
module.exports = Complicated
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const mongoose = require('mongoose')
2+
3+
const { Schema } = mongoose
4+
5+
const PageSchema = new Schema({
6+
title: {
7+
type: String,
8+
required: true,
9+
},
10+
content: {
11+
type: String,
12+
required: true,
13+
},
14+
}, { timestamps: true })
15+
16+
const Page = mongoose.model('Page', PageSchema)
17+
18+
module.exports = Page
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const mongoose = require('mongoose')
2+
const { Schema } = mongoose
3+
4+
const UploadsSchema = new Schema({
5+
path: String,
6+
filename: String,
7+
mimeType: String,
8+
size: Number,
9+
})
10+
11+
const Uploads = mongoose.model('Uploaded', UploadsSchema)
12+
13+
module.exports = Uploads

0 commit comments

Comments
 (0)