본문 바로가기

분류 전체보기

(291)
Node.js 숙련 주차 개인 과제_2 Node.js 숙련 주차 개인 과제_2 📌 게시글 API 📌 Post 모델 생성(Terminal) npx sequelize model:generate --name Post --attributes title:string,content:string,userId:integer Id → postId 수정 userId를 외래키로 user모델과 연결 📄 /models/post.js 'use strict'; const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => { class Post extends Model { /** * Helper method for defining associations. * This method is..
Node.js 숙련 주차 개인 과제_1 Node.js 숙련 주차 개인 과제_1 📌 회원가입 & 로그인 API 📌 Terminal npm init -y npm i sequelize mysql2 -S npm i sequelize-cli -D npx sequelize init 📄 /config/config.json "development": { "username": "root", "password": "비밀번호", "database": "database_development", "host": "엔드포인트", "dialect": "mysql" }, 📌 기존 User 테이블 삭제 쿼리문 DROP TABLE `database_development`.`Users` DROP TABLE `database_development`.`SequelizeMeta` 📌..
내일배움캠프 4기_Node숙련 28일차 TIL 내일배움캠프 4기_Node숙련 28일차 TIL https://pangeei-h.tistory.com/entry/Nodejs-%EC%88%99%EB%A0%A8-1%EC%A3%BC%EC%B0%A85 Node.js 숙련 1주차_5 Node.js 숙련 1주차_5 MySQL 📌 RDS생성 📌 RDS 설정 📌 인바운드 규칙 편집 📌 mysql install 📌 mysql 연결 host : 연결/보안 > 엔드포인트 user : root 비밀번호 : 비밀번호 입력 express_db 생성된걸 확인할 수 pangeei-h.tistory.com https://pangeei-h.tistory.com/entry/Nodejs-%EC%88%99%EB%A0%A8-1%EC%A3%BC%EC%B0%A86
코딩 테스트 연습 21일 코딩 테스트 연습 21일 프로그래머스, 평행 📄 나의 코드 dots = [[1, 4], [9, 2], [3, 8], [11, 6]] def solution(dots): answer = 0 x1 = dots[0][0] x2 = dots[1][0] x3 = dots[2][0] x4 = dots[3][0] y1 = dots[0][1] y2 = dots[1][1] y3 = dots[2][1] y4 = dots[3][1] if (y1 - y2) / (x1 - x2) == (y3 - y4) / (x3 - x4): answer = 1 if (y1 - y3) / (x1 - x3) == (y2 - y4) / (x2 - x4): answer = 1 if (y1 - y4) / (x1 - x4) == (y2 - y3) / (..
Node.js 숙련 1주차_6 Node.js 숙련 1주차_6 Sequelize 📌 Terminal npm init -y npm i sequelize mysql2 -S npm i sequelize-cli -D npx sequelize init 📄 /config/config.json "development": { "username": "root", "password": "비밀번호", "database": "database_development", "host": "엔드포인트", "dialect": "mysql" }, 📌 데이터베이스 생성하기 npx sequelize db:create 📌 User 모델 생성 npx sequelize model:generate --name User --attributes email:string,nickname..
Node.js 숙련 1주차_5 Node.js 숙련 1주차_5 MySQL 📌 RDS생성 📌 RDS 설정 📌 인바운드 규칙 편집 📌 mysql install 📌 mysql 연결 host : 연결/보안 > 엔드포인트 user : root 비밀번호 : 비밀번호 입력 express_db 생성된걸 확인할 수 있다. SQL문 📄 데이터베이스 생성 CREATE DATABASE NodeJS; 📄 테이블 생성 CREATE TABLE IF NOT EXISTS courses ( id bigint(5) NOT NULL AUTO_INCREMENT, title varchar(255) NOT NULL, tutor varchar(255) NOT NULL, PRIMARY KEY (id) ); 📄 데이터 삽입 INSERT INTO courses (title, tuto..
내일배움캠프 4기_Node숙련 27일차 TIL 내일배움캠프 4기_Node숙련 27일차 TIL https://pangeei-h.tistory.com/entry/Nodejs-%EC%88%99%EB%A0%A8-1%EC%A3%BC%EC%B0%A83 Node.js 숙련 1주차_3 Node.js 숙련 1주차_3 Middle Ware 웹 서버의 요청/응답에 대해 공통적으로 관리 📄 app.js app.use(express.json()); // post, put 전달된 body데이터를 req.body로 사용할 수 있도록 만든 bodyparser app.use((req, res, next) => pangeei-h.tistory.com https://pangeei-h.tistory.com/entry/Nodejs-%EC%88%99%EB%A0%A8-1%EC%A3%BC%E..
코딩 테스트 연습 20일 코딩 테스트 연습 20일 프로그래머스, 안전지대 📄 나의 코드 board = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]] def solution(board): x = [] y = [] for i in range(len(board)): for j in range(len(board)): if board[i][j] == 1: x.append(i) y.append(j) x_min = x[0]-1 if x[0]-1 >= 0 else 0 x_max = x[-1] + 2 if x[-1] + 2 = 0 else 0..
Node.js 숙련 1주차_4 Node.js 숙련 1주차_4 로그인 & JWT 구현 📄 app.js const jwt = require("jsonwebtoken"); // 로그인 router.post("/auth", async(req,res) => { const {email, password} = req.body; const user = await User.findOne({email}); // 사용자가 존재하지 않거나, // 입력받은 password와 사용자의 password가 다를 때 에러메세지가 발생해야 한다. if(!user || password !== user.password){ res.status(400).json({ errorMessage: "사용자가 존재하지 않거나, 사용자의 password와 입력받은 password가 ..
Node.js 숙련 1주차_3 Node.js 숙련 1주차_3 Middle Ware 웹 서버의 요청/응답에 대해 공통적으로 관리 📄 app.js app.use(express.json()); // post, put 전달된 body데이터를 req.body로 사용할 수 있도록 만든 bodyparser app.use((req, res, next) => { console.log('Request URL:', req.originalUrl, ' - ', new Date()); next(); }); app.use('/api', [postsRouter, commentsRouter]); //API가 사용되기 위한 라우터 등록 next() : 다음 스택으로 정의된 미들웨어 호출 사용자 인증이나 logging에 쓰임. 여러 개의 미들 웨어 📄 app.js a..