Git Product home page Git Product logo

api.serlo.org's Introduction

Serlo Logo

serlo.org โ€“ API

Unified GraphQL API for Serlo.

Kanban board

Setup

You need Docker, Node.js and Yarn installed on your system.

Now follow the upcoming instructions.

Clone

# Clone the project:
$ git clone https://github.com/serlo/api.serlo.org.git
$ cd api.serlo.org

Development

Install dependencies

Run yarn to install the dependencies of all packages and run yarn build to build also the packages 'authorization' and 'types'.

Start

Make sure Docker is running and then run yarn start to start Redis.

Run tests

  • yarn test runs the unit tests (requires yarn start:redis beforehand)
  • yarn pacts runs the contract tests (requires yarn start:redis beforehand)
  • yarn check:all runs all checks (like the linter and tests) to check whether your codebase is ready to be merged into main

Use the GraphQL playground

After yarn start, you can open the GraphQL playground via http://localhost:3000/___graphql.
Note that most queries will need a running serlo/serlo.org-database-layer dev environment.

If you need to run requests authenticated/authorized, use yarn auth to be authenticated as user with id 1 or yarn auth <id> to choose a specific user.

Happy coding!

Stop

Interrupt the yarn start command to stop the dev server and run yarn stop:redis to stop Redis.

Automatically check your codebase before pushing

You can use git hooks to automatically check the whole codebase before you push to the server. To configure it, run the following commands in the root directory:

echo "yarn check:all --no-uncommitted-changes" > .git/hooks/pre-push
chmod +x .git/hooks/pre-push

With git push --no-verify you can bypass the automatic checks.

Repository structure

  • __fixtures__ contains test data (used by both unit and contract tests).
  • __tests__ contains the unit tests.
  • __tests-pacts__ contains the contract test.
  • src/internals contains a couple of internal data structures. In most cases, you won't need to touch this. Here we hide complexity that isn't needed for typical development tasks.
  • src/model defines the model.
  • src/schema defines the GraphQL schema.

We have ~ as an absolute path alias for ./src in place, e.g. ~/internals refers to ./src/internals.

Other commands

  • yarn build builds all packages. Run it when package authorization changed.
  • yarn build:server builds the server (only needed for deployment)
  • yarn changelog generates the changelog (only needed for deployment)
  • yarn deploy:images deploys the docker images to our Container Registry (only needed for deployment)
  • yarn format formats all source code
  • yarn lint lints all source code
  • yarn license updates license headers in source files
  • yarn pacts runs the contract tests
  • yarn test runs the unit tests
  • yarn codegen generates TypeScript types from GraphQL schema
  • yarn start spins up the development environment
  • yarn update-version starts the process for adding a new version (only needed for deployment)

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.