Giter VIP home page Giter VIP logo

joo-json-server's Introduction

joo-json-server

LGTM

Install

$ npm install json-server
$ npm install json-server --prefix . // 폴더 내 설정

Usage

  • Create a db.json file($ vi db.json)
cat db.json

{
  "posts": [
    { "id": "1", "title": "a title", "views": 100 },
    { "id": "2", "title": "another title", "views": 200 }
  ],
  "comments": [
    { "id": "1", "text": "a comment about post 1", "postId": "1" },
    { "id": "2", "text": "another comment about post 1", "postId": "1" }
  ],
  "profile": {
    "name": "typicode"
  },
  "kms": [
    { "id": "1", "name": "kim"},
    { "id": "2", "name": "hong"}
  ]
}

Run

$ npx json-server db.json

JSON Server started on PORT :3000
Press CTRL-C to stop
Watching db.json...

( ˶ˆ ᗜ ˆ˵ )

Index:
http://localhost:3000/

Static files:
Serving ./public directory if it exists

Endpoints:
http://localhost:3000/posts
http://localhost:3000/comments
http://localhost:3000/profile

FROM

Fly.io

  1. branch 및 pr 생성 0.1.0/fly
  2. Dockerfile 생성($ vi Dockerfile)
$ cat Dockerfile

FROM node:20.11

WORKDIR /app

RUN npm install -g npm

RUN npm install -g json-server

COPY ./db.json /app

CMD ["json-server", "-p", "80", "-w", "/app/db.json"]

  1. https://fly.io/ 가입 - (주의! hobby plan 가입)
  2. 무료 플랜 : https://fly.io/docs/about/pricing/#free-allowances
  3. install cmd - https://fly.io/docs/hands-on/install-flyctl/
sudo curl -L https://fly.io/install.sh | sh
  1. vi ~/.zshrc 밑에 내용 추가
# fly
export FLYCTL_INSTALL="~/.fly"export PATH="$FLYCTL_INSTALL/bin:$PATH"
  1. 확인
$ tail -n 3 ~/.zshrc
# fly
export FLYCTL_INSTALL="~/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"

$ source ~/.zshrc
$ flyctl auth login
  1. Setting(fly.toml 수정)
$ cat fly.toml

# fly.toml app configuration file generated for joo-json-server on 2024-02-04T12:53:39+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'joo-json-server'
primary_region = 'nrt'

[build]

[http_service]
  internal_port = 80
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 3
  processes = ['app']

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 256

  1. Launch
$ flyctl launch

⚠️ Do you want to tweak these settings before proceeding? Yes

? Create .dockerignore from 1 .gitignore files? No

image

  1. Setting(fly.toml 수정)
$ cat fly.toml

# fly.toml app configuration file generated for joo-json-server on 2024-02-04T12:53:39+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'joo-json-server'
primary_region = 'nrt'

[build]

[http_service]
  internal_port = 80
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 3
  processes = ['app']

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 256

  1. Deploy
$ flyctl deploy

image

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.