내컴퓨터에서 소스코드가 변경될떄마다 build를 해야하는 번거로움이 있다
volumes를 설정하게되면 변경된 소스코드를 동일시 하게 해준다.
nodemon으로 변경된 소스코드를 refresh 해준다.
경로 : 내현재위치 파일명:docker위치 파일명
build:
context: .
dockerfile: Dockerfile
volumes:
- ./index.js:/myfolder/index.js
index.js 의 변경사항일 있으면 refresh가 가능해진다
build:
context: .
dockerfile: Dockerfile
volumes:
- ./src:/myfolder/scr
src폴더에서 소스코드를 관리하게 되면 모든 소스코들을 변경될떄 마다 refresh가 가능해진다
moels라는 폴더 생성
schma.js 파일 생성
mongoose 쿼리문은 구글링 !
import mongoose from 'mongoose';
const boardSchema = new mongoose.Schema({
writer: String,
title: String,
contents: String,
// 데이터 타입 지정
});
export const Board = mongoose.model('Board', boardSchema);
위처럼 내가 원하는 컬렉션 명(boardSchena로 정의) 하고 데이터 타입을 지정
- Mongoose Scham 는 필터링해주는 것이다.
- Mongo compass에서 넣으면 스키마 상관없이 들어간다.
- mongoDB는 스키마리스다(스키마가 정의되지 않았다.)`
브라우저 주소창은 API GET요청하는 도구(rest-api)
응답결과가 html 이면 읽고 해석한후 변화해서 나타내준다, 텍스트 라면 그냥 화면에 송출
meta 태그 og(open graph)
개발자들의 약속
const createMessage = async () => {
// 입력된 메시지 : "안녕하세요 https://www.naver.com 에 방문해 주세요!"
// 1. 입력된 메시지에서 http로 시작하는 문장이 있는지 먼저 찾기!(.find() 등의 알고리즘 사용하기)
const url = 'https://www.naver.com';
// 2. axios.get으로 요청해서 html코드 받아오기 => 스크래핑
const result = await axios.get(url);
// 3. 스크래핑 결과에서 OG(오픈 그래프) 코드를 골라내서 변수에 담기 => cheerio 도움 받기
const $ = cheerio.load(result.data);
$('meta').each((index, el) => {
if ($(el).attr('property') && $(el).attr('property').includes('og:')) {
const key = $(el).attr('property'); // og:title, og:description, ...
const value = $(el).attr('content'); // 네이버, 네이버 메인에서 ~~~
console.log(key, value);
}
});
};
결과