ayapingping-js

3.0.27 • Public • Published

AyaPingPing JS

A starter pack framework in NodeJS for building REST API applications.

npm package

version build language download dependents issue last_commit license

const appjs = require('ayapingping-js')(__dirname);

appjs.get('/my-route', 'myController');

appjs.listen();

Features

  • Using the power of ExpressJS
  • Allows you to use most of ExpressJS operations (using express function)
  • Easy implementation & customization
  • Controller-based routing
  • Focus on simplicity & performance
  • Plugin mechanism (custom plugin & built in plugin)
  • Executable for generating applications project structure quickly (./node_modules/.bin/ayapingping-js-create)

Docs

  • For full documentation, visit the Wiki

Getting started

Installation

ayapingping-js tersedia di NPM package manager. Untuk menginstall, pertama buat dulu folder project Anda dan masuk kedalam folder tersebut:

mkdir my-project
cd my-project

Kemudian, install ayapingping-js dengan perintah berikut:

npm install ayapingping-js

Setelah proses install berhasil, eksekusi perintah berikut untuk membuat working directory dari ayapingping-js:

./node_modules/.bin/ayapingping-js-create

Perintah diatas akan membuat folders dan files baru seperti: app.js, .env, controllers, dll yang dibutuhkan untuk memulai menggunakan ayapingping-js.

Getting the latest version

Gunakan perintah berikut untuk melakukan update ayapingping-js ke versi yang terbaru:

npm update ayapingping-js

Basic usage

ayapingping-js berbasis ExpressJS. Bagi yang familiar dengan ExpressJS tentu akan lebih mudah. Untuk menggunakan ayapingping-js, silahkan install terlebih dahulu sesuai dengan petunjuk installasi diatas. Masuk ke folder project Anda, kemudian buka terminal baru dan eksekusi file app.js menggunakan perintah berikut ini untuk menjalankan aplikasi:

node app.js

Anda juga bisa menggunakan pm2 untuk menjalankan ayapingping-js. Contoh:

pm2 start app.js

Jika berhasil, maka akan muncul keterangan "Application is live!" seperti ini:

https://lh3.googleusercontent.com/pw/ACtC-3fXyv2-V38wmHj798L2v3rf_d_wel3p2qIlZY5QiuW5ugQT_Lt_DM9OitVxRIOR6wwDStl0bmdnyFPu4jmsqBvWRUo2W9rUdPMt_JuoGsQUi4DUp6VRjienxLK3ysuXfv9svqeXNtReyVF7hXYPChR7=w714-h214-no

Anda kemudian dapat melakukan request ke url dan port tersebut—Anda juga bisa test dengan membuka browser ke -> http://localhost:3000.

Simple routing (ayapingping-js style)

Anda bisa membuat route sederhana di app.js dengan format seperti berikut:

appjs.get('/my-route', 'myRouteController');

Kemudian, di folder controller buat file bernama myRouteController.js dan isikan:

'use strict';

module.exports = function(proto, req, res, next) {
  res.send('Hello world!');
};

Route baru berhasil dibuat. Jika Anda mengakses route GET '/my-route', maka Anda akan mendapatkan response "Hello world!".

ayapingping-js adalah controller-based. Jadi setiap route harus memiliki controller untuk menghandle logic utamanya.

Simple routing (ExpressJS style)

Anda juga bisa membuat route di app.js dengan gaya ExpressJS seperti berikut ini:

appjs.express((proto, app) => {
  // ExpressJS style
  app.get('/my-route', (req, res, next) => {
    res.send('Hello world!');
  });
  app.get('/my-route-2', (req, res, next) => {
    res.send('Hello world! Again!');
  });
});

Contributing

Follow the Contributing Guide (updated soon).

People

Thanks to all people who took their time to contribute to this project.

List of all contributors

Release

Changelog

Read at CHANGELOG.md

Credits

Copyright © 2020 - 2021 Dali Kewara

License

MIT License

Package Sidebar

Install

npm i ayapingping-js

Weekly Downloads

0

Version

3.0.27

License

MIT

Unpacked Size

83.7 kB

Total Files

35

Last publish

Collaborators

  • dalikewara