ACore-Node-Server
Pages (Latest 10 updated) : Menu (Edit):
Contents:
  1. ACORE-NODE-SERVER
    1. Getting started
      1. local environment
      2. with docker
    2. Documentation
      1. How does it work?
      2. TODO:
      3. Directory structure
      4. How to extend and customize

ACORE-NODE-SERVER

Acore-Node-Server is a modular nodejs application written in TS/JS that exposes GraphQL and Rest API useful to create any kind of applications based on azerothcore database. It supports the fetching of nesting data from multiple realms, graphql subscriptions (websockets) to implement real-time data, integrated Access Control Layer, user registration and pass recovery system, integration with Wordpress and many other features.

It can be extended and customized with new features and extra databases support.

Getting started

local environment

  1. clone this repo
  2. run npm install
  3. copy files in /conf/dist folder under conf/ folder and configure them with your connection info
  4. run npm run db:all && npm run start
  5. Open the url showed in your console to browse the graphql playground where you can get all the documentation about the APIs

with docker

Work in progress…

Documentation

How does it work?

ACore-Node-Server uses a set of libraries and strategies to automate the creation of GraphQL APIs for the AzerothCore database

The current flow is composed by 2 + 1 (optional) different steps:

  1. (optional) /apps/generator: Script to generate sequelize modules from a sequelize compatible connection (MySQL etc). Acore-node-server already includes default pre-generated models. However, if you need to generate your custom one. You can set your /conf and run it. Generated models should not be modified manually because the generator can overwrite them. Instead you need to use our adapters as a middleware to extend/replace functionalities.

  2. RealmMgr: this is a file that can be found in our /src. This file is the core of this project since it’s in charge of:
    • Load all sequelize models dynamically (imports are not statically coded inside our sources allowing you to load your custom tables). It will load them based on your /conf/ files that support also multiple realms.
    • Generate GraphQL schemas with the graphcraft library
    • Apply our middlewares (and your custom ones) to add functionalities such as: relationships between tables that are not present in AzerothCore schema, Access Control Layer for tables and fields based on user role and custom APIs to extends basic CRUD operations.
  3. Apollo GraphQL server: the schemas generated by the RealmMgr file will be merged and passed to the Apollo Server that will run with an integrated Playground

Main dependencies used:

  • azerothcore/js-common:agnostic code written in TS/JS shared by all JS based projects. Whenever a method is so generic that is not related to any business logic and framework, it will be placed here.

  • graphcraft: library used by acore-node-server to implement the automatic conversion of sequelize models into GraphQL APIs. We actively contribute to this 3rd party project

  • apollographql: complete framework for both client and server to implement GraphQL APIs

And many other more that will be described soon!

TODO:

  • Improve documentation
  • Auto-generate tables for the entire database
  • create the relationships between tables and the ACL layer for all entities using our middlewares (adapters)
  • create the test layer with jest
  • move generic service code (apollo configuration etc) in a separated npm package to be shared/reused by other projects.

Directory structure

/src

  • /database -> sequelize models + seeders
  • /logic -> RealmMgr, adapters, entities & APIs
  • /service -> apollo, express and everything is related to the starting phase
  • index.ts -> export methods and objects
  • run.ts -> used by package.json script to run the service

  • JSDOC documentation

  • test coverage

How to extend and customize

Work in progress…