runtime-server
v1.1.1
Published
a server for running virtual stacks
Downloads
2
Readme
Runtime-Server
Overview
This is a back-end server for running virtual stacks in NoStack
. It enables three things primarily:
- Actions: actions enabled specifically for a given set of users on a given stack. They are dynamically defined based on data in the neo4j graph database. The
execute
mutation runs an action. - Auth: the auth is handled using a specific Cognito User Pool that is dedicated to a given stack. Most of the mutations are for auth.
- Queries: retrieving the data for a "unit". The
uniData
andsource
queries provide that information.
Every stack has an id, which for convenience is the user pool id. Any information about users and other data is stored in the database. Until a virtual stack is exported, all information about a stack, including it's actions, is retrieved dynamically as needed. The clientId can be retrieved with the platformInfo
query.
Deployment
This is a serverless app. See the serverless.yml file. See the intro of the nostack backend wiki for how to deploy using serverless.
Queries
The server is developed on top of apollo-server-lambda
and neo4j
. It provides 3 queries and 2 mutations as the resolvers.
Queries: - platformInfo - unitData - source Mutations: - createUserOnPlatform - execute - resendConfirmation - forgotPassword - resetForgottenPassword - confirmSignUp - login - refreshToken - verifyToken
This authentication is based on the AWS Cognito authentication.
The auth helper functions are contained in the auth
directory.
- login: /src/auth/login/index.js
- registerUser: /src/auth/registerUser/index.js
- confirmSignUp: /src/auth/confirmSignUp/index.js
- resendConfirmCode: /src/auth/resendConfirmCode/index.js
- forgotPassword: /src/auth/forgotPass/index.js
- confirmForgotPassword: /src/auth/confirmForgotPass/index.js
- refreshToken: /src/auth/refreshToken/index.js
- verifyToken: /src/auth/verifyToken/index.js
actions
This actions should be called by the excute
mutation with actionType.
The actions helper functions are contained in the actions
directory.
- createInstance: /src/actions/createInstance/index.js
- createInstanceAssn: /src/actions/createInstanceAssn/index.js
- createInstanceUnknownParent: /src/actions/createInstanceUnknownParent/index.js
- deleteInstance: /src/actions/deleteInstance/index.js
- removeInstanceAssn: /src/actions/removeInstanceAssn/index.js
- updataInstance: /src/actions/updateInstance/index.js
- updateInstanceAssn: /src/actions/updateInstanceAssn/index.js
- source: /src/actions/source/index.js
- submitForm: /src/actions/submitForm/index.js
- unitData: /src/actions/unitData/index.js
utils
This includes some functions to call the action with actionTypes. The excute
mutation refers to this functions. The main function is /src/utils/callModuleToExecuteAction.js
.
typeDefs
This part is a definition part for the queries and mutations, and types for them.
The main function is /src/typeDefs/index.js
.
Config
This includes three functions for the awsInfo
, databaseInfo
and dbSession
.
- awsInfo:
/src/config/awsInfo.js
- databaseInfo:
/src/config/databaseInfo.js
- dbSession:
/src/config/getSession.js
Info
Git Repository
```link
<https://github.com/NoStackApp/runtime-server>
```
Endpoints
- POST - [nostackapp.github.io/multitask](https://osc6oeg32a.execute-api.us-east-1.amazonaws.com/dev/graphql)
- GET - [nostackapp.github.io/multitask](https://osc6oeg32a.execute-api.us-east-1.amazonaws.com/dev/graphql)
- cerificated endpoint: <https://api.nostack.net/graphql>
Location
hosted directly from an S3 Bucket: https://s3.console.aws.amazon.com/s3/buckets/runtime-server-dev-serverlessdeploymentbucket-km6ift2kg5ju?region=us-east-1&tab=objects
Routing
The routing is done in Route53.
Certificates
Certificates are handled via the Certificate Manager. The most important ones are for *.nostack.net
and *.pivotate.com
.
globalActionIdToActionType
```info
'a0d89c1f-c423-45e0-9339-c719dcbb7afe': actionTypes.LOGIN,
'1279e113-d70f-4a95-9890-a5cebd344f3d': actionTypes.VERIFY_USER_TOKEN,
'96d3be63-53c5-418e-9167-71e3d43271e3': actionTypes.REFRESH_USER_TOKEN,
'afd0c972-8f72-47ea-8313-94f895c4f87a': actionTypes.CONFIRM_SIGNUP,
'25bfdd78-6a2c-11eb-9439-0242ac130002': actionTypes.RESEND_CONFIRM
```
But currently it is unnecessary because we separate the authentication part from the action.
Update
This project is based on the serverless framework so it is maintained using the serverless framework. In this server, you can find the serverless specification in the file ~/serverless.yml
.
To deploy the latest version, you must:
- install serverless globally:
npm install -g serverless
- configure AWS credentials:
serverless config credentials --profider aws --key <your aws access key> --secret <your aws secret key> --profile custom-profile
- run
sls deploy
locally.
We are running everything from within us-east-1 on AWS.
Testing
You can run npm test
and npm run coverage
. Or, there's an integration test: npm run int-test
with live data.
There's an original test set, integration tests written in jest, apparently by Bruth. Don't touch those with a ten foot pole. To run those, you supposedly have to copy .env.example to .env, add the info requested, and then you can run them.