Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exam1 nguyen thi thu huong #61

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 0 additions & 7 deletions .env.template

This file was deleted.

78 changes: 75 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,83 @@
# HIT_NodeJS_2023

Bài tập về nhà lớp NodeJS

## Hướng dẫn

- Clone project về máy \
`git clone https://github.com/hit-haui/HIT_NodeJS_2023.git`
`git clone https://github.com/hit-haui/HIT_NodeJS_2023.git`
- Tạo nhánh mới theo tên buổi kèm theo tên của mình \
`git checkout -b btvn-buoi5/dinh-tan-hung`
`git checkout -b btvn-buoi5/dinh-tan-hung`
- Install package và code thôi \
`npm install` hoặc `npm i`
`npm install` hoặc `npm i`
- Sau khi hoàn thành task push lên nhánh của mình **(Không push lên nhánh main)**

## Còn tiếp ...

# 1

npm init -y

npm i express

npm i nodemon -D

create server.js
const express = require('express')
const app = express()

app.get('/', function (req, res) {
res.send('Hello World')
})

app.listen(3000)

.gitignore
node_modules

# 2 env

create .env
PORT=
create .env.template

npm i dotenv -D

# 3 mongodb

npm i mongoose

setup
const mongoose = require('mongoose');

MONGODB_URI = mongodb://127.0.0.1:27017/test

mongoose.connect(process.env.MONGODB_URI)
.then(() => console.log('Connected!')).catch(err =>console.log('err'))

### model Blog

const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const blogSchema = new Schema({
name: {
type: String,
required: true,
},
image: {
type: String,
},
data: {
type: String,
},
});
const Blog = mongoose.model("Blog", blogSchema);
module.exports = {
Blog,
};

# 4

controller
router
=> commit
12 changes: 12 additions & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/mime.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/nodemon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/nodemon.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/nodemon.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/nodetouch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/nodetouch.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/nodetouch.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/nopt.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/nopt.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/semver.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/semver.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading