Skip to content

Commit 01a6d3d

Browse files
chore: 🤖 add Blog and Comment model, controller, swagger
1 parent a343124 commit 01a6d3d

File tree

7 files changed

+66
-30
lines changed

7 files changed

+66
-30
lines changed

‎src/controllers/Blog.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function BlogController() {}
2+
3+
export default new BlogController();

‎src/controllers/Comment.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function CommentController() {}
2+
3+
export default new CommentController();

‎src/models/Blog.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import mongoose from "mongoose";
2+
3+
const BlogSchema = new mongoose.Schema(
4+
{
5+
blogId: {
6+
type: Number,
7+
required: true,
8+
unique: true
9+
},
10+
title: {
11+
type: String,
12+
trim: true,
13+
required: true
14+
},
15+
content: {
16+
type: String,
17+
trim: true,
18+
required: true
19+
},
20+
userId: {
21+
type: String,
22+
trim: true,
23+
required: true
24+
}
25+
},
26+
{ versionKey: false }
27+
);
28+
29+
const BlogModel = mongoose.model("Blog", BlogSchema);
30+
export default BlogModel;

‎src/models/Comment.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import mongoose from "mongoose";
2+
3+
const CommentSchema = new mongoose.Schema(
4+
{
5+
commentId: {
6+
type: Number,
7+
required: true,
8+
unique: true
9+
},
10+
content: {
11+
type: String,
12+
trim: true,
13+
required: true,
14+
unique: true
15+
},
16+
userId: {
17+
type: String,
18+
trim: true,
19+
required: true
20+
}
21+
},
22+
{ versionKey: false }
23+
);
24+
25+
const CommentModel = mongoose.model("Comment", CommentSchema);
26+
export default CommentModel;

‎src/models/User.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,10 @@ const AutoIncrement = Inc(mongoose);
44

55
const UserSchema = new mongoose.Schema(
66
{
7-
username: {
8-
type: String,
9-
trim: true,
10-
required: true,
11-
unique: true,
12-
minLength: 5,
13-
maxlength: 16
14-
},
15-
email: {
16-
type: String,
17-
trim: true,
18-
required: true,
19-
unique: true,
20-
minlength: 16,
21-
maxlength: 40
22-
},
23-
phoneNumber: {
24-
type: String,
25-
trim: true,
26-
minLength: 10,
27-
maxlength: 10,
28-
default: ""
29-
},
30-
password: {
7+
walletAddress: {
318
type: String,
329
trim: true,
33-
required: true
10+
default: null
3411
},
3512
fullName: {
3613
type: String,
@@ -61,11 +38,6 @@ const UserSchema = new mongoose.Schema(
6138
type: Boolean,
6239
default: false
6340
},
64-
walletAddress: {
65-
type: String,
66-
trim: true,
67-
default: null
68-
},
6941
sharksFollowed: {
7042
type: Array,
7143
default: []

‎src/swaggers/blog.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Online Swagger yaml file formatter: https://editor.swagger.io/

‎src/swaggers/comment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Online Swagger yaml file formatter: https://editor.swagger.io/

0 commit comments

Comments
 (0)