Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
TaeMinY committed Mar 27, 2020
0 parents commit f5626a7
Show file tree
Hide file tree
Showing 19 changed files with 12,602 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"watch": [
"src"
],
"ext": "ts",
"exec": "ts-node ./src/app.ts"
}
6,890 changes: 6,890 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "tsnode",
"version": "1.0.0",
"description": "",
"main": "./src/app.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "sudo pm2 start src/app.ts",
"stop": "sudo pm2 delete app",
"db": "sudo pm2 start mongod --dbpath ./db",
"dev": "cross-env nodemon ./src/app.ts",
"build": "webpack --config webpack.config.js",
"buildtsc": "nodemon tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/cors": "^2.8.6",
"@types/crypto-js": "^3.1.43",
"@types/dotenv": "^8.2.0",
"@types/mongoose": "^5.7.1",
"@types/morgan": "^1.7.37",
"@types/shortid": "0.0.29",
"bcrypt-nodejs": "0.0.3",
"compression": "^1.7.4",
"cors": "^2.8.5",
"cross-env": "^6.0.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"fs": "0.0.1-security",
"helmet": "^3.21.2",
"http": "^0.0.0",
"jsonwebtoken": "^8.5.1",
"lowdb": "^1.0.0",
"mongodb": "^3.5.3",
"mongoose": "^5.8.11",
"morgan": "^1.9.1",
"multer": "^1.4.2",
"nodemailer": "^6.4.2",
"path": "^0.12.7",
"pm2": "^4.2.3",
"shortid": "^2.2.15",
"ts-lint": "^4.5.1",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.2",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
},
"devDependencies": {
"@types/express": "^4.17.2",
"@types/node": "^12.12.27",
"nodemon": "^2.0.2",
"typescript": "^3.7.5"
}
}
12 changes: 12 additions & 0 deletions pm2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"apps": [
{
"name": "Test",
"script": "./src/app.ts",
"autorestart": true,
"watch": false,
"max_memory_restart": "1G",
"log_file": "combined.log"
}
]
}
33 changes: 33 additions & 0 deletions src/Model/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { model, Schema, Model, Document } from 'mongoose';
const userSchema = new Schema({
username: {
type: String,
required: true
},
password: {
type: String,
required: true
},
email: {
type: String,
required: true
},
profile_image : {
type: String,
required:true
},
userdata:{
type: Object,
required:true
}
});
export interface UserDocument extends Document {
username: string;
password: string;
enckey: string;
email: string;
profile_image : string;
userdata: any;
}
const User: Model<UserDocument> = model('user', userSchema);
export default User;
32 changes: 32 additions & 0 deletions src/Model/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { model, Schema, Model, Document } from 'mongoose';
const commentSchema = new Schema({
post_id: {
type: String,
required: true
},
email:{
type: String,
required:true
},
text:{
type: String,
required:true
},
time:{
type: String,
required:true
},
name:{
type: String,
required:true
}
});
export interface CommentDocument extends Document {
post_id: string;
email: string;
text: string;
time: string;
name: string;
}
const Comment: Model<CommentDocument> = model('comment', commentSchema);
export default Comment;
43 changes: 43 additions & 0 deletions src/Model/post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { model, Schema, Model, Document } from 'mongoose';
const postSchema = new Schema({
data: {
type: Object,
required: true
},
text: {
type: String,
required: true
},
like: {
type: Number,
required: true
},
like_users: {
type: [String],
required: true
},
time: {
type: String,
required: true
},
email:{
type:String,
required:true
},
name:{
type:String,
required:true
}

});
export interface PostDocument extends Document {
data: any;
text: string;
like: any;
like_users: any;
time : string;
email: string;
name:string;
}
const Post: Model<PostDocument> = model('post', postSchema);
export default Post;
4 changes: 4 additions & 0 deletions src/Module/Send.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function Send(res, status:Number, mes?:string, result?: boolean ,token?: string,userdata?:object) {
res.status(status).send({result,mes,token,userdata}).end();
}
export default Send;
12 changes: 12 additions & 0 deletions src/Module/connectDB.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require('mongoose');
require('dotenv').config();

const MONGO_URL = process.env.DB_HOST || 'mongodb://localhost:27017/sunrin';
const env = process.env.NODE_ENV || 'development';

let mongoURL: any = MONGO_URL;
if (env !== 'production') mongoURL += `_${env}`;
if (env === 'development') {
mongoose.set('debug', true);
}
module.exports = () => mongoose.connect(mongoURL);
Loading

0 comments on commit f5626a7

Please sign in to comment.