Giter Site home page Giter Site logo

muse-fastify-starter's Introduction

Muse Fastify Starter

Pengenalan

Ini adalah starter template atau source code yang dicipta khas untuk handle backend punya proses. Starter template ini dibina menggunakan :

  • Nodejs (version 8+)
  • Fastify

Langkah Mula

# clone repository
git clone [email protected]:mansarip/muse-fastify-starter.git my-server

# masuk dalam folder yang baru diclone
cd my-starter

# remove remote git asal
git remote remove origin

# install semua depedencies
yarn install

Development

Untuk mulakan development server, run command ini :

$ yarn run dev

Secara default, PORT yang akan digunakan ialah 3001. Jadi kita boleh cuba dengan melayari ke http://localhost:3001.

Jika ingin menghidupkan server dengan PORT yang lain, kita boleh letakkan value pada argument PORT sebelum kita run command yarn run dev, contohnya :

$ PORT=4001 yarn run dev

Dengan ini, server development akan dijalankan pada PORT 4001.

Deployment (Production)

Saya cadangkan untuk guna pm2 sebagai process manager untuk deployment pada production. pm2 akan membenarkan server kita (nodejs app) berjalan secara background.

Jadi, untuk gunakan pm2, kita perlu install ia secara global :

npm install -g pm2

atau kalau guna Yarn :

yarn global add pm2

Kemudian baru kita boleh run start file :

# file process.json ada dalam repo ini sebagai contoh
pm2 start process.json

Untuk memastikan ia berjalan, kita boleh cuba dengan melayari http://localhost:6001.

Sila rujuk bahagian di bawah berkenaan PORT.

Environment

Jika kita lihat dalam file process.json, kita dapati ada satu key namanya env. Dalam ruang tersebut, kita boleh define apa sahaja key dan value untuk environment yang akan digunakan semasa production.

Contoh :

"env": {
  "NODE_ENV": "production",
  "PORT": 6001
}

Key NODE_ENV adalah sangat penting untuk disetkan valuenya kepada production supaya server kita berjalan dengan behaviour yang sepatutnya.

muse-fastify-starter's People

Contributors

mansarip avatar

Watchers

James Cloos avatar  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.