Git Product home page Git Product logo

service-template-node's Introduction

service-template-node

Template for creating MediaWiki Services in Node.js

Getting Started

Installation

First, clone the repository

git clone https://github.com/wikimedia/service-template-node.git

Install the dependencies

cd service-template-node
npm install

You are now ready to get to work!

  • Inspect/modify/configure app.js
  • Add routes by placing files in routes/ (look at the files there for examples)

You can also read the documentation.

Running the examples

The template is a fully-working example, so you may try it right away. To start the server hosting the REST API, simply run (inside the repo's directory)

npm start

This starts an HTTP server listening on localhost:6927. There are several routes you may query (with a browser, or curl and friends):

  • http://localhost:6927/_info/
  • http://localhost:6927/_info/name
  • http://localhost:6927/_info/version
  • http://localhost:6927/_info/home
  • http://localhost:6927/{domain}/v1/siteinfo{/prop}
  • http://localhost:6927/{domain}/v1/page/{title}
  • http://localhost:6927/{domain}/v1/page/{title}/lead
  • http://localhost:6927/ex/err/array
  • http://localhost:6927/ex/err/file
  • http://localhost:6927/ex/err/manual/error
  • http://localhost:6927/ex/err/manual/deny
  • http://localhost:6927/ex/err/auth

Tests

The template also includes a test suite a small set of executable tests. To fire them up, simply run:

npm test

If you haven't changed anything in the code (and you have a working Internet connection), you should see all the tests passing. As testing most of the code is an important aspect of service development, there is also a bundled tool reporting the percentage of code covered. Start it with:

npm run-script coverage

Issue Tracking

We use Phabricator to track and create new issues. See the list of open issues and feel free to submit a new one.

Docker

The docker-start and docker-test scripts are deprecated, and only remain for backwards compatibility. Instead, developers should configure .pipeline/blubber.yaml and install Blubber to generate the desired Dockerfile.

To see the Dockerfile generated by blubber, ensure the blubber CLI is setup and execute:

blubber .pipeline/blubber.yaml {variant}

where variant is one of either build, development, test, etc. in blubber.yaml.

In place of docker-test, to run your service's tests, execute:

blubber .pipeline/blubber.yaml test | docker build --tag service-test --file - .
docker run service-test

In place of docker-start, to run your service, execute:

blubber .pipeline/blubber.yaml production | docker build --tag service-node --file - .
docker run service-node

Troubleshooting

In a lot of cases when there is an issue with node it helps to recreate the node_modules directory:

rm -r node_modules
npm install

Enjoy!

service-template-node's People

Contributors

akosiaris avatar berndsi avatar cdanis avatar clarakosi avatar d00rman avatar dependabot[bot] avatar eevans avatar gwicke avatar hknustwmf avatar jdforrester avatar kartikm avatar kostajh avatar krinkle avatar mdholloway avatar mvolz avatar nikitavbv avatar nikkhn avatar nyurik avatar ottomata avatar pchelolo avatar sbassett29 avatar shdubsh avatar thesocialdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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