Skip to content

j33f/yggdrasil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yggdrasil

CircleCI codecov Depfu

Quality Gate Status Maintainability Rating Bugs Code Smells Technical Debt Lines of Code

Security Rating Vulnerabilities

License apache2

Yggdrasil is a versatile ready to use backend.

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

In developpment ! DO NOT USE AS IS !!!!

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

Start in dev mode :

You will need to have Docker and Docker-compose installed and configured.

npm start

This will launch the server stack (redis, mongo, backend) via docker (killing existing containers if needed) using the ./start-dev script

The server is started when you see this :

backend    | time: ⏱  Starting Yggdrasil took 4s213ms
backend    | info: 🤘  Yggdrasil is up and running !

Testing

Unit and Functional tests

You first need to have the stack running (for functional tests), then use the npm test command.

The coverage reporter is istambujs/nyc

Linter only

Just run npm run test:lint

The tests are performed by eslint, and use .eslintrc.json file.

Unit tests only

Just run npm run test:unit

The unit test coverage details information are located in the coverage dir.

The tests are performed by mocha, and use sinon, should and rewire.

The tests files resides alongside with the files they are testing. Some helpers can be found in the unitTests directory.

The mocha config used can be found in the .mocharc.yml file.

Functional tests only

Just run npm run test:func

The functional test coverage details information are located in the coverage.functional dir.

The tests are performed by cucumber and the features files can be obviously found in the features directory.

You need to perform the tests directly into the /var/yggdrasil directory onto the docker container or just have a started stack (the npm command is smart enough to launch the tests into the container by itself).

Features

Configuration

Yggdrasil uses the defaultConfig.json file as a configuration base.

As Yggdrasil uses the rc module, you can also use your very own configuration, via :

  • command line arguments, parsed by minimist (e.g. --foo baz, also nested: --foo.bar=baz)
  • environment variables prefixed with ${yggdrasil}_
    • or use "__" to indicate nested properties (e.g. yggdrasil_foo__bar__baz => foo.bar.baz)
  • a local .${yggdrasil}rc or the first found looking in ./ ../ ../../ ../../../ etc.
  • $HOME/.${yggdrasil}rc
  • $HOME/.${yggdrasil}/config
  • $HOME/.config/${yggdrasil}
  • $HOME/.config/${yggdrasil}/config
  • /etc/${yggdrasil}rc
  • /etc/${yggdrasil}/config

OAuth Strategies

The currently supported OAuth strategies are: Google, Facebook, GitHub, Microsoft and Twitter.

See OAuth Strategies Readme for further details.

HTTP & SocketIO

Yggdrasil serves HTTP routes via the good old Express framework along with a SocketIO server.

Both of them are secured by an authorization system based on JWT;

By default, all routes ans SocketIO accesses requires the JWT token to be present (and valid) except the ones used to sign-in, re-create a password, or public files

Data storage

Yggdrasil uses Mongo as primary storage and Redis for cache. Everything is put in Redis then Mongo so that yggdrasil can absorb a huge amount of calls.

Redis is also used to store user sessions.

File storage

By default, the local strategy is used, and the files are stored into the container where Yggdrasil lives. A S3 storage strategy is in development.

Rights management

Users rights are managed by an advanced yet simple "policies tree" and allow you to fine-tune things to meet your needs.

Troubleshoot

I have dirty docker images and volumes

Clean your docker environment :

docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker network prune -f
docker rmi -f $(docker images --filter dangling=true -qa)
docker volume rm $(docker volume ls --filter dangling=true -q)
docker rmi -f $(docker images -qa)

Mongo is in a dirty mess after a system crash

In case of a system crash, some mongoDB data files could be irremediably corrupted. To get a clean stack, just do

  • docker-compose -r docker-compose/dev.yml kill
  • sudo rm -rf /data/mongo
  • restart the stack
  • launch the ./mongoRestore script
  • enjoy your day

Licence

Copyright 2020 Jean-François Vial

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Backend based on NodeJS, Express, SocketIO, Mongo and Redis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published