본문 바로가기

Project/TIL

(24)
20.03.17 ShareBook TIL 회원가입을 위한 signup server api를 작성해 보았다. import { Router, Request, Response, NextFunction } from 'express'; import { Users } from '../../../models/Users'; const singup = Router(); singup.post('/', async (req: Request, res: Response, next: NextFunction) => { const { name, nickname, email, password, gender, region } = req.body; try { const users = await Users.findOne({ where: { email: email, password:..
20.03.16 ShareBook TIL TypeScript-Sequelize를 이용하여 데이터베이스를 생성해보기로 하였다. 일단 user table 하나를 만들기 위해 어떻게 해야하는지 여러 레퍼런스들 찾아보았다. class 문법으로 작성하는 것도 있고 table @ 이런 문법으로 작성하는 것도 있어서 어떻게 적용해야하는지 감이 오질 않았다. 먼저 config 폴더를 만들고 database.ts를 만들었다. // config/database.ts import { Sequelize } from 'sequelize-typescript'; import 'dotenv/config'; export const sequelize = new Sequelize({ database: 'sharebook', dialect: 'mysql', username: pr..
20.03.15 ShareBook TIL Router Controller 설정 // src/interfaces/controller.interface.ts import { Router } from 'express'; interface Controller { path: string; router: Router; } export default Controller; // src/routes/users/users.controller.ts import express, { Request, Response, NextFunction } from 'express'; import Controller from '../../interfaces/controller.interface'; // import express = require('express'); class U..
20.03.14 ShareBook TIL public listen(){ const PORT: number = Number(process.env.PORT) || 4000 this.app.listen(PORT , 0 => { // { console.log(`Server listen on PORT ${PORT}`); }); } private initMiddlewares() { // 미들웨어 사용 this.app.use(cors()); this.app.use(morgan('dev')); this.app.use(bodyParser.json()); this.app.use(cookieParser()); } private initRouter() { this.app.use(this.router); this.router.get(`${this.path}`, thi..
20.03.13 ShareBook TIL 어제는 분명히 server가 작동하였는데 추가 미들웨어들을 설치하고 다시 실행하니 에러가 발생하였다. 그래서 TypeScript형식으로 작성하지 않아서 그런가 싶어서 레퍼런스들을 찾아보았다. 참고 레퍼런스 https://coldsewoo.com/blog/category/web/backend/Typescript/20190920002 [Typescript #3] express 기본 설정 [Typescript #3] express 기본 설정 coldsewoo.com 레퍼런스를 보며 작성해보았지만 import express, { Application, Request, Response } from 'express'; import cors from 'cors'; import bodyParser from 'body-..
20.03.12 ShareBook TIL 킥오프 미팅으로 조언을 받은 뒤 스키마 수정 유저와 도서 테이블에서 굳이 join 테이블이 있어야할 정도로 bareminimum이 크지 않다고 판단 데이터베이스에 어떻게 유저가 찍은 사진을 넣을까? => 사진파일을 서버가 받아서 S3에 저장 => 이미지 url을 받는다?! 좀더 찾아봐야겠다. Typescript node&express 사용 sudo npm i -g typescript typescript 설치 tsc --version 버전 확인 app.ts 생성 tsc init tsconfig.json 생성 tsconfig.json에서 { "target": "es6", "outDir": " ./dist", "rootDir": "./src", "moduleResolution": "node" } 주석제거 및 ..
20.03.11 ShareBook TIL oven으로 보며 각 페이지 화면 구성 회의 기능 flow 작성 task 카드 작성 도서 리스트에서 대여 요청, 대여 중, 반납완료 등등 이런 대여상태는 데이터베이스에 상태값을 컬럼 하나로 정리해 볼 수 있다 도서 동시 요청시에는 Rock 기능을 사용해 볼 수 있다(단점 반응속도문제, 데이터베이스 엔진 문제...) bare minimum 스키마 구성 내가 생각 해본 유저와 책에 대한 스키마
20.03.10 ShareBook TIL 팀명 : five fingers 프로젝트 명 : ShareBook 프로젝트 내용 / 목적 : 우리 동네 중고 책 대여 사용 할 예상 스택 프론트엔드 React Native // Redux // Material UI TypeScript 백엔드 (본인 Role) nodejs & express MySQL & Sequelize JWT AWS TypeScript 좀 더 구체적인 기능 flow가 필요하고 팀원분들과 계속 상의 예정이다. TypeScript를 적용하기 위해 개인적 공부가 필요하고 개인적으로는 초반에 스키마 관계 설정을 확실히 잡아가야 된다고 생각한다. 개인적으로 작게 만들어본 UI https://ovenapp.io/view/fZeJ0r694hfSRa5DHjhtbw3mDPKaVwUl/wgS59 로그인 ..