Coder Social home page Coder Social logo

112-1-unit1-trello-clone's Introduction

Web Programming HW#1

Reference

Run the project

If you only want to run the project, you can follow the steps below.

1. Clone the project

Please find the .zip download link of HW1: My Diary at https://wp.ee.ntu.edu.tw/.

picture 3

2. Install dependencies

cd backend
yarn

3. Run the server

yarn start

4. Open the frontend

Open frontend/index.html by clicking it in your file explorer.

Or if you're on ubuntu, you can run the following command to open it in your browser.

cd frontend
xdg-open index.html

If you're on macOS, you can run the following command to open it in your browser.

cd frontend
open index.html

Notes

Coding with MongoDB

ref

export const getTodos const method

ref

要用 const 來保證這個 method 沒有 side effects,即不會更動到 caller。

Destructuring Assignments

ref

const { title, description } = req.body;

// equals to

const title = req.body.title;
const description = req.body.description;

(req, res) 怎麼知道 caller method 是 put?

ref

picture 2

因此,只要前端打過來的是,例如:…/api/todos/12345,那 id 就會收到 12345

建立一個 “Promise” 的 MongoDB 連線!

其實應該可以用 async/await ,老師說之後示範。

Problems

  1. lint 的部分應該放在 setup 後面?
  2. 這裡 merge 有問題

Setup

Frontend Setup

1. Create a vite project

$ yarn create vite
yarn create v1.22.17
✔ Project name: … frontend
✔ Select a framework: › React
✔ Select a variant: › TypeScript

cd frontend
yarn
yarn dev

Backend Setup

1. Create a backend folder

mkdir backend

2. Create a package.json file

cd backend
yarn init -y

3. Install dependencies

yarn add express cors mongoose dotenv body-parser

4. Typescript setup

yarn add -D ts-node typescript @types/cors @types/node @types/express

-D: dev only

Then we create a tsconfig.json file

yarn tsc --init

5. Create an entry point

mkdir src
touch src/index.ts

6. Add scripts to package.json

"scripts": {
  "dev": "nodemon src/index.ts",
  "start": "ts-node src/index.ts",
  "lint": "eslint src",
  "format": "prettier --write src"
}

Do this after the linters are set up

Add the following line to tsconfig.json. Now we can import from @lib/* instead of ../../../lib/*.

{
  "compilerOptions": {
    ...
    "@lib/*": ["../lib/*"], // <--- Do NOT add this line

    // Use This Instead // ISSUE
    "paths": {
      "@lib/*": ["../lib/*"]
    }
    ...
  }
}

112-1-unit1-trello-clone's People

Contributors

andrewchiull avatar madmaxieee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.