Skip to content

NDLANO/api-documentation

Repository files navigation

NDLA api-documentation

CI

Requirements

  • Node.JS 20.9
  • npm 9
  • Docker (optional)

Getting started

What's in the box?

  • Express
  • Babel (ES6)

Dependencies

All dependencies are defined in package.json and are managed with yarn. To initially install all dependencies and when the list dependency has changed, run yarn.

$ yarn

Start development server

Start node server with hot reloading middleware listening on port 3001.

$ yarn start

To use a different api set the NDLA_API_URL environment variable.

Unit tests

Test framework: ava with enzyme.

$ yarn test

Do you tdd?

$ yarn run tdd

Code style

tl;dr: Use eslint! Rules: [Airbnb Styleguide]https://github.com/airbnb/javascript.

Lint code with eslint, including eslint react plugin, eslint-plugin-import, eslint-plugin-jsx-a11y. Beside linting with globally installed eslint, eslint can be invoked with npm:

$ npm run lint

Rules are configured in ./.eslintrc.js and extends eslint-config-airbnb. If feeling brave, try eslint --fix.

Other scripts

# Run with NODE_ENV=production:
$ npm run start-prod
# Docker stuff
$ ./build.sh

Dependencies

Please update this section if you add or remove dependencies. Hint: Running npm ls --long --depth 0 prints a list of dependencies including a brief description.

Server

express: Fast, unopinionated, minimalist web framework http://expressjs.com/

nodemon: Simple monitor script for use during development of a node.js app. http://nodemon.io

compression Node.js compression middleware https://github.com/expressjs/compression#readme

cors Middleware for dynamically or statically enabling CORS in express/connect applications https://github.com/expressjs/cors/

Util

defined: return the first argument that is !== undefined. https://github.com/substack/defined

lodash: Lodash modular utilities. https://lodash.com/

cross-env Run commands that set environment variables across platforms https://github.com/kentcdodds/cross-env

parse5 WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.js https://github.com/inikulin/parse5

ES2015/6

babel-register: babel require hook https://babeljs.io/

babel-preset-es2015: Babel preset for all ES2015 plugins. https://babeljs.io/

babel-polyfill: Polyfill for a full ES2015 environment https://babeljs.io/

babel-preset-react: Babel preset for all React plugins. https://babeljs.io/

babel-plugin-transform-object-rest-spread: Compile object rest and spread to ES5 https://babeljs.io/

babel-plugin-transform-async-to-generator Turn async functions into ES2015 generators https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-async-to-generator

isomorphic-fetch: Isomorphic WHATWG Fetch API, for Node & Browserify. https://github.com/matthew-andrews/isomorphic-fetch/issues

Testing

ava Futuristic test runner 🚀 git+https://github.com/avajs/ava.git

Code style

eslint: An AST-based pattern checker for JavaScript. http://eslint.org

babel-eslint Custom parser for ESLint https://github.com/babel/babel-eslint

eslint-plugin-babel An eslint rule plugin companion to babel-eslint https://github.com/babel/eslint-plugin-babel#readme

eslint-config-airbnb: Airbnb's ESLint config, following their styleguide https://github.com/airbnb/javascript

eslint-plugin-import: Import with sanity. https://github.com/benmosher/eslint-plugin-import

eslint-plugin-jsx-a11y: A static analysis linter of jsx and their accessibility with screen readers. https://github.com/evcohen/eslint-plugin-jsx-a11y#readme

eslint-plugin-react: React specific linting rules for ESLint. https://github.com/yannickcr/eslint-plugin-react