본문 바로가기

express

(30)
UdemyAPI_Define model schema User Schema const mongoose = require('mongoose'); const UserSchema = new mongoose.Schema({ name: { type: String, required: [true, 'Please add a name'] }, email: { type: String, required: [true,'Please add an email'], unique: true, match: [ /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/, 'Please add a valid email' ] }, role: { type: String, enum: ['user', 'instructor'], defalut: 'user' }, passwo..
"Udemy" API by myself What do I have to do first? 1. Define model schemas 2. Inspector/User CRUD + ErrorHandler middleware 3. Course CRUD 4. Review CRUD (all objects CURD is public till this step) 5. put Authentication and Permission - User/Instructor Register / Encrypting password / Authentication: JWT / Auth Protect / Role Authorization - User CRUD - Course CRUD - Review CURD 6. Detail Query - Filtering/ Sorting/ S..
Udemy course spec/APIs Courses List all courses in the database - Pagination - Select specific fields(category) in result - Limit number of results - Filter by fields Search Course by user input Get single course Create new course - Authenticated users only - Must have the role "instructor" - Field validation via Mongoose - Photo will be uploaded to local filesystem(required:false) Update course - Instructor only - Va..
How to manage of 1:N relationship? mongoose https://mongoosejs.com/docs/tutorials/virtuals.html recommand look this site slowly. I wondered how models are related each other and how they work? MongoDB is noSQL(: Not only SQL) so I needed to change the relationship of models. Because I just know RDBMS. RDBMS is sophisticate to defining models. but mongoDB is not that much. 1. In 1:N relationship, only 'N' object has foreignkey. '1' object ..
The process error handling 1. Occured some Error. ex. inputed ungettable type of object or bad request 2. If we let the error be/ if we dont do anything with this error, the server is shut donwed. so we need to controll or handle errors. 3. Catch errers ! use "try { } catch { }" or anything we can. I made some middleware to catch err and connect with handler const asyncHandler = fn => (req, res, next) => Promise.resolve(f..
회원 가입 1. User 모델 생성 const mongoose = require('mongoose'); const UserSchema = new mongoose.Schema({ name: { type: String, required: true }, email: { type: String, required: true, unique: true }, password: { type: String, required: true }, date: { type: Date, default: Date.now } }); module.exports = User = mongoose.model('user', UserSchema); 2.필수적인 데이터 조건에 맞게 들어왔는지 확인. [check('name', 'Name is required')..
express api 분석 1."dependencies" 코드 출처는 여기. https://github.com/bradtraversy/devconnector_2.0 시작은 dependencies부터. { "name": "devconnector", "version": "1.0.0", "description": "Social network for developers", "main": "server.js", "scripts": { "start": "node server", "server": "nodemon server", "client": "npm start --prefix client", "dev": "concurrently \"npm run server\" \"npm run client\"", "heroku-postbuild": "NPM_CONFIG_PRODUC..
Thinkster node.js API 강의 후기. https://thinkster.io/topics/node Node.js Tutorials and Courses - Thinkster The best place on the web for tutorials and screencasts covering AngularJS, Ionic, Swift, MEAN, and more! thinkster.io 튜토리얼 괜찮은 걸 찾다가 발견했다. medium 클론 강의. 프론트단, 백단에 여러가지 있고 각각의 프레임워크들이 구현하는 것은 똑같은 medium 클론 사이트였다. 이 강의 사이트의 시작은 "똑같은 것을 여러가지 언어로 구현해 놓으면 새로운 언어를 배우기가 쉽지 않을까?" 라는 생각이라고 한다. 이게 내 맘에 들었고 가격도 한달에 30달러여서 바로 결제했다. ..