Giter VIP home page Giter VIP logo

alkem-io / server Goto Github PK

View Code? Open in Web Editor NEW
24.0 11.0 4.0 25.59 MB

Core server in the Alkemio platform, offering a GraphQL api for interacting with the logical domain model.

Home Page: http://alkem.io

License: European Union Public License 1.2

TypeScript 99.35% JavaScript 0.09% Dockerfile 0.03% Shell 0.47% Jsonnet 0.06%
graphql graphql-server node typeorm typescript challenges projects society graphql-api docker

server's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

server's Issues

Fix default DB host

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Publish NPM package to simplify working with CT model via GraphQL

As a client that is interacting with a CT server, I want to have an npm package available that I can use to interact with the CT server. To include

  • a set of CT types so that I can effectively use the data retrieved from an ecoverse instance
  • a set of functions to allow me to submit new data

Acceptance criteria:

  • package easily available via NPM install

Questions: do we need to establish a CherryTwist organisation profile on NPM registery?

Setup ESLint

The reason for this issue is that currently the project does not provide unified code formatting. Which will lead to messy and not well formatted code in the future. Configuring this at the beginning of the project will make our life easier in the future, the code will be well structured and easy to read.

Some ideas how to configure it.
https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project

Most common things to discuss:

  • single vs double quotes
  • tab size: 2 vs 4 spaces
  • do we want to have linter check before a PR can be merged?

Any suggestions are welcome

Why ESLint over TSLint? The future of TypeScript on ESLint

Prototype of integration with AAD + capture of implications / options

Description

As a partner who deploys an instance of CT, I want to be able to authenticate users of the platform using a centralised identity provider so that people can use the platform.

The first partner deployment is Odyssey Momentum, but before that we need to have identity / authentication embedded in the Demo.Simple application.

Acceptance criteria

  • Able to authenticate to CT using a few default accounts
  • Able to authenticate from the web client
  • Capture of implications / billing for using AAD

Authorisation design for now separate

TBD - what happens when a new user is added into CT? Do they automagically get an account within the identity provider? Onboarding?

Additional Context

Groups for a challenge limited in scope to the challenge

Description

As a user I want that the groups for a challenge are just available within the context of the challenge so that I can manage them independently from the groups in other challenges

Acceptance criteria

  • userGroups field at the ecoverse level only returns groups for the ecoverse (so not any groups from challenges)
  • userGroups field at the challenge level only returns groups for a particular challenge

Note: we may need a design discussion about adding additional queries.

Additional Context

Helm Chart for Server

Description

As a developer
I want helm charts
So that I can deploy cherrytwist/server to k8s

Acceptance criteria

  • helm chart is used for deployment of cherrytwist/server to k8s
  • all variables can be properly set with values from github actions (or externally)
  • deployment is tested reaching on dev.cherrytwist.org/api

Additional Context

Default setup not working out of the box

Describe the bug
Doing a docker-compose up as per the instructions results in a docker stack that is not running.

Finally, is the .env.default still needed? I tried removing it but got other errors showing up so I put it back as was not sure where it was picked up from

To Reproduce
Steps to reproduce the behavior:

  1. Clean checkout locally
  2. Follow docker instructions
  3. Go to localhost:4000/graphql - get an error. Looking at the console in docker I saw: "Unable to establish database connection: Error: connect ECONNREFUSED 192.168.176.2:3306"
  4. by stopping the server container (but leaving the db running) and then starting again it runs

Looks like a race condition whereby the db is not available when the server first tries to connect and it does not retry thereafter. Fix: order the startup with a lapse or have the server retry after a failed connection?

Logging capability inside Server

Description

As a developer I want to have robust + flexible logging that I can configure at runtime so that I can get insight into what is happening on the server at multiple levels of granularity.

Acceptance criteria

  • Chosen logging package (Winston) integrated with console / file output
  • Agreed set of initial logging areas e.g. authentication, api usage, system (bootstrap etc)
  • Existing logging updated to use the new logging areas

Logging package requirements

  • Different levels of logging supported
  • Different outputs supported / easily extensible.
  • Easy integration with Kibana
  • Different outputs for different log levels
  • Log rolling for files
  • Different categories
  • Well documented

Additional Context

After a quick scan by usage:

  • loglevel - 9m weekly downloads - very basic implementation
  • winston - 5m weekly downloads
  • log4js - 2m weekly downloads
  • bunyan - 1m weekly downloads

Good articles on the subject:
https://www.loggly.com/blog/a-benchmark-of-five-node-js-logging-libraries/
https://www.npmtrends.com/log4js-vs-loglevel-vs-winston
https://developer.ibm.com/technologies/node-js/tutorials/learn-nodejs-winston/
https://npmcompare.com/compare/bunyan,log4js,winston

Authentication support on server

Description

As a user of CT I want to be able to authenticate myself so that I have access to the application.

Acceptance criteria

  • OpenID Connect library chosen + added to the server
  • Able to accept authentication tokens from the client and use them to validate authentication with the Identity Provider
  • No access to api if client is not authenicated
  • Authentication can be enabled / disabled via configuration on the server. Default is off (for development workflows)
  • Documentation udpated in Server repo regarding authentication flag and configuration

Additional Context

User & UserGroup profiles to include references

Description

As a deployer I would like to be able to store the e.g. github handles of users so that they can be displayed as part of the user profile

e.g. techsmyth as Neil's github handle

Acceptance criteria

  • References as part of a user profile e.g. github url
  • User profile able to store multiple handles i.e. generic

Additional Context

THIS EXCLUDES AUTHORISATION

Documentation of api

Description

As a developer I want documentation within the graphql schema so that I can effectively use it.

Acceptance criteria

  • All types to have descriptions, judged by the reviewer to be understandable by a developer
  • Non-trivial fields to also have descriptions

Additional Context

Several fields have size limits that cause uploads to fail

Describe the bug
Uploading the sample challenge files from Odyssey triggers a number of field size limits

To Reproduce
Steps to reproduce the behavior:

  1. Go to Odyssey ecoverse repo + download the sample files
  2. Use the uploader in the demo project to upload them

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Make it easy to get started with the Server

Description

As a contributor I want that it is very easy to get a running server going so that I can quickly test it out.

Acceptance criteria

  • add default configuration
  • update docker compose files to use the variable from the .env file
  • update documentation to describe known problems that may be encountered
  • update documentation to have two target use cases (a) getting the server quickly running based on docker-compose (b) doing development based on "npm start" & then using a mysql container for the db potentially

Additional Context

Add db_reset script

Description

As a developer I want an easy way to reset the server back to an empty database so that I can continue my testing

Acceptance criteria

  • new script added to package.json called "db-reset" that just resets the db to an empty state
  • remove the reset functionality from the current script, so that it only loads sample data
  • rename the current script to be "db-sample-data"
  • update the readme documentation to detail out the usage of the two scripts
  • drop + re-create database scripts

Additional Context

Storage of docker images on docker registry

Description

As a developer I want to be easily able to access docker images for CT containers so that I can easily get development / test environments running.

Note: tags now part of the development ways of working

Acceptance criteria

  • CherryTwist repo on docker registry
  • First docker images stored on docker registry and usable
  • CT icon added

Additional Context

Support adding/updating groups on entities with groups

Description

As a user of the api, I want to be able to add/update groups to all entities that have groups so that I can via a compact api work with the data

Acceptance criteria

  • add the following methods: addUserToGroup(groupID, userID), createGroupOnChallenge/Ecoverse(groupName)
  • Creation of groups should ensure names are unique within the context they are being created.

References with names + descriptions

Description

As a challenge owner I want to be able to store references with additional information such as a label and a description so that the rational behind the reference is clear. >

Acceptance criteria

  • Possible to store references within a context
  • Extended db population script to also populate challenges with reference data

Additional Context

Missing ORM config

Describe the bug
It is not possible to reset the db at the moment

To Reproduce
Steps to reproduce the behavior:

  1. Check out latest version of master
  2. run npm install and then npm run test-db-reset
  3. get a failure about no connection

Does the documentation need to be updated?

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Load sample challenge from json file

Description

As a developer I want to be able to load sample data in from a json file to avoid having to update all images via code

Acceptance criteria

  • Example challenge stored in a json file
  • reset-db script able to load the json file, instantiate a Challenge object fully populated from it
  • Sample challenge added as part of the script for reseting the database

Additional Context

Refactor api

Description

As a developer working with the graphql api I want to have a clean api that exposes the right set of data so that I can easily navigate the model.

To include:

  • making the queries and data model to be more in line with the approach used in the following service: https://spacexdata.herokuapp.com/graphql
  • implies using mostly lowercase and less like method names; also need to reduce the set of information exposed via the api

Acceptance criteria

  • [] Updates api
  • [] Updated client.web to interface with the updated api

Additional Context

Remote reseting of an ecoverse instance to an empty state

Description

As a developer I want to be able to carry out commands related to the state of the data managed by the server remotely so that the server can be put back into a known state.

Acceptance criteria

  • End point to allow the eoverse to be reset back to an empty state
  • Readme updated to reflect how to use this

Additional Context

Support develop / master dual branch setup in server

Description

As a developer I want to have two levels of branches so that there is multiple levels of quality visible.

Acceptance criteria

  • Additional "develop" branch
  • CI build updated to trigger off develop
  • Rules enforced on develop similar to what is there currently on master

Additional Context

Members users field at all level

Description

As a user of the CT api, I want to be easily able to access the members at each level of the hierarchy so I can intuitively navigate the structure.

Acceptance criteria

  • members query at the Ecoverse level that returns UserGroup
  • members field at the Challenge level that returns UserGroup
  • script for the population of the database with sample data updated to populate the members user groups

Additional Context

Generation and pushing of docker image with correct tag based on package.json version number

Description

As a developer I would like to have an easy way to generate a new docker image for the server that is tagged with the version number and pushed to the registry

@@ look at https://github.com/ryanramage/docker-build-run-push

Acceptance criteria

  • Ability for a developer to trigger building a new docker image that picks up the version number and applies it as a tag to the generated image
  • Ability to push this image to the public registry

Additional Context

Extend connection factory to use ormconfig + migration support is enabled

Description

As a developer I want a connection factory so that migrations can take place and it is also simply better that the parameters are specified in a config file(i.e. entries that are not environment specific)

Acceptance criteria

  • add typeorm static and default configuration to .env.default and .env.docker
  • Update readme to detail out using .env.default for local development
  • migrations are enabled between versions of the database schema e.g. update the db schema

Additional Context

Name for docker-compose stack + name containers

Description

As a developer I want a recognisable name for the docker-compose'd stack from the server project, and that containers have names so can reliably populate the db data.

Acceptance criteria

  • Name for the docker-composed stack to be "cherrytwist-server"
  • Both containers have clear names that can be referrred to from docker commands
  • README updated to use new container name

Additional Context

Support nested mutations

Description

As a developer I want to be able to execute nested mutations on the api so that I can execute updates that have multiple levels

The issue is with lazy loaded nested input types in a Promise call within type-graphql.

Acceptance criteria

  • Should ‹testable condition that should be satisfied›

Additional Context

Updating a challenge results in an error

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to graphql interface
  2. put in the query + variable from the update-challenge sample
  3. Execute the querey - get the following error:

"error": {
"errors": [
{
"message": "Variable "$challengeData" of required type "UpdateRootChallengeInput!" was not provided.",
"locations": [
{
"line": 1,
"column": 26
}
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"GraphQLError: Variable "$challengeData" of required type "UpdateRootChallengeInput!" was not provided.",
" at _loop (/usr/src/app/node_modules/graphql/execution/values.js:94:17)",
" at coerceVariableValues (/usr/src/app/node_modules/graphql/execution/values.js:121:16)",
" at getVariableValues (/usr/src/app/node_modules/graphql/execution/values.js:50:19)",
" at buildExecutionContext (/usr/src/app/node_modules/graphql/execution/execute.js:206:61)",
" at executeImpl (/usr/src/app/node_modules/graphql/execution/execute.js:104:20)",
" at Object.execute (/usr/src/app/node_modules/graphql/execution/execute.js:63:35)",
" at /usr/src/app/node_modules/apollo-server-core/src/requestPipeline.ts:548:22",
" at Generator.next ()",
" at /usr/src/app/node_modules/apollo-server-core/dist/requestPipeline.js:8:71",
" at new Promise ()"
]
}
}
}
]
}

Allow selective disabling of authentication

Description

As a developer I want to be able to selectively disable authentication for when I am developing

Note: for now default is off

Acceptance criteria

  • Env var picked up that enables authentication

Additional Context

Tags creatable + updateable

Description

As a user of the api, I want to be able to add tags to any taggable entity so that I can via a compact api work with the data

Acceptance criteria

  • ability to add tags to the followinging entities: User, UserGroup, Ecoverse, Challenge, ...

Additional Context

Note: may involve creating a "Profile" type entity on the above entities

Update ORM mapping to store data properly

Description

As a developer I want that the ORM mapping layer is able to save the entities together with child entities in one transaction

Acceptance criteria

  • A single save on the ecoverse saves the full ecoverse hierarchy

Additional Context

Create docker image for node based server

Description

As a developer I want to be able to craete a docker image from the node based server

Acceptance criteria

  • Should ‹testable condition that should be satisfied›

Additional Context

Change GraphQL Data Source from SQLite to mySQL

Description

As a developer I would like to change the GraphQL data source to mySQL.

Acceptance criteria

  • CT data is persisted in mySQL data store.
  • GraphQL can retrieve data from the store.
  • mySQL is added as part of a multi-stage build process for the server container.

Additional Context

According to TypeORM official documentation only mySQL, SQL Server and PostgreSQL support transactions.

Design for injecting business logic

Description

As host organisation deploying a Cherrytwist instance, I want to be able to inject custom business logic into the operation of the server so that I can add my own business rules into the events on the server

Acceptance criteria

  • Design for how business logic can be injected into the server

Additional Context

Image management for users, groups & challenges

Description

As a user I want to be able to store images with the users, groups and challenges so that I can manage that visual information together with the relevant text.

Key support needed:

  • avatars for users
  • logos for groups, challenges

Size guidelines / restrictions?
How would this data would be migrated / pulled from another environment?
Where is the data stored?

Acceptance criteria

  • Able to store and retrieve an avatar with the user
  • Able to store + retrieve the logo for a group and a challenge

Additional Context

Sample export from Odyssey below.
{"id":1258044,"name":"John Doh","email":"[email protected]","first_name":"John","last_name":"Doh","avatar":{"url":"https://d3evbfoo20rmgo.cloudfront.net/uploads/user_organization/avatar/1258044/556974af-77ef-4263-877b-e9ae565d38d8.jpg","thumb":{"url":"https://d3evbfoo20rmgo.cloudfront.net/uploads/user_organization/avatar/1258044/thumb_556974af-77ef-4263-877b-e9ae565d38d8.jpg"},"small_thumb":{"url":"https://d3evbfoo20rmgo.cloudfront.net/uploads/user_organization/avatar/1258044/small_thumb_556974af-77ef-4263-877b-e9ae565d38d8.jpg"},"mini_thumb":{"url":"https://d3evbfoo20rmgo.cloudfront.net/uploads/user_organization/avatar/1258044/mini_thumb_556974af-77ef-4263-877b-e9ae565d38d8.jpg"}},"groups":[{"is_admin":false,"id":29565,"name":"Global Odyssey Community","status":"accepted","last_invited_in":null},{"is_admin":false,"id":29579,"name":"Track 'Nature 2.0'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":29580,"name":"Track 2019 'Scaling Ecosystems'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":29584,"name":"Track 2019 'Digital Nation’s Infrastructure'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":29589,"name":"Track 'Fossil Free Future'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":29629,"name":"Track 2019 '21st Century Digital Citizenship'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":31139,"name":"Jedi 2019","status":"accepted","last_invited_in":null},{"is_admin":false,"id":31830,"name":"Odyssey Hackathon 2019","status":"accepted","last_invited_in":null},{"is_admin":false,"id":35978,"name":"Track 'Conscious Cities'","status":"accepted","last_invited_in":null},{"is_admin":false,"id":39369,"name":"PrivateTracer","status":"accepted","last_invited_in":1585912554171}],"fields":{},"is_registered":true,"created_at":1545337073581,"updated_at":1598534611216}

Population of empty ecoverse

Description

As a developer I want that the server initialises with a clean default state that can then have additional data populated.

Acceptance criteria

  • Separate script to reset the database to the default empty state
  • Code / files to set the default state

Additional Context

Contributors on-boarding process improvements

Description

As a new contributor
I want to start contributing as fast as possible
So that we need to update documentation to cover all prerequisites for new contributors to get project up and running.

Acceptance criteria

  • Documentation updated to mention specific MySQL server configurations.
  • .env.sample - sample environment variable configuration file distributed with the project.

Expanded technical stack + design for Server

Description

As a contributor I want to be able to be a full overview of the technical stack and dependencies used on the server so that I can quickly be effective on the project / make decisions on using the solution.

Acceptance criteria

  • Layered diagram of the server components (visual)
  • Expanded rational of the components used by the server, including usage of MySql instead of Sqlite3
  • Logical vs physical data model
  • Developer setup documentation to be able to contribute
  • Updated logical data model in coordination/design/techdesign.md

Additional Context

user profile data to be retrieved from Identity Provider

Description

As a maintainer of the system I want the user profile fields to be retrieved from AAD where possible so that information is not duplicated in multiple places.

Acceptance criteria

  • User fields retrieved from Identity Provider + exposed via graphql api: first name, last name, email

Additional Context

Update version to 0.1.2

Description

As a contributor I want to be able to get the latest version using the Demo.Simple project

Acceptance criteria

  • package.json version number updated to 0.1.2
  • image based on this available with the 0.1.2 tag on dockerhub

Additional Context

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.