No description
- Go 97.4%
- Shell 1.9%
- Dockerfile 0.7%
| auth | ||
| configs | ||
| db | ||
| httpControllers | ||
| httpMiddleware | ||
| messaging | ||
| utils | ||
| .gitignore | ||
| build.sh | ||
| debug.sh | ||
| deploy.sh | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| Procfile | ||
| readme.md | ||
Graph database-based API Server Template
Template for a business API server based on neo4j graph database to store and query data.
Features
- JWT-based authentication with either phone or email address, and password
- Email address verification (code sent via templated email)
- Phone number verification (code sent via SMS)
- Messaging: SMS (via Twilio integration)
- Messaging: Basic & Templated Emails (via Mailjet integration)
- Query neo4j nodes by specifying any combination of labels and properties
- TODO Query neo4j relationships by specifying any combination of directionality, labels, properties
including node labels and properties. - TODO Payments: One-off and regular (via Stripe integration)
- Get status of sent emails and SMS.
- TODO Randomized tests for workflows:
- User registration, login, and refresh
- Email verification (includes 'send email' test)
- Phone verification (includes 'send SMS' test) - Serve static files.
How to use this template
- Clone this repository to a local directory.
- Create a
.jwkSigPairSet.jsonfile in./configs.
This will be the key that the server will use to sign (and verify) JWK tokens used for authentication.
You may create the key using this tool.. - Create a
.envfile in./configs, specifying environment vars: (OPTIONAL, you can always set these elsewhere i.e. Dockerfile or cloud platform e.g. AWS, Google Cloud, or Heroku)- NEO4J_URI — URI of the neo4j database.
- NEO4J_USERNAME — Username to log into the neo4j database.
- NEO4J_PASSWORD — Password to log into the neo4j database.
- MAILJET_API_KEY — To use Mailjet to send emails. Obtain from web console.
- MAILJET_SECRET_KEY — To use Mailjet to send emails. Obtain from web console.
- TWILIO_ACCOUNT_SID — To use Twilio to send SMS. Obtain from web console.
- TWILIO_AUTH_TOKEN — To use Twilio to send SMS. Obtain from web console.
- Create a
.configs.jsonfile in./configs, paste the following, then enter your own values:
{
"TwilioPhoneNumber": <string>,
"AuthTokenValidForMins": <int>,
"VerificationCodeValidForMins": <int>,
"AppName": <string>,
"EmailFromAddress": <string>,
"EmailFromName": <string>,
"VerificationEmailTemplateId": <int>,
"Port": <int>
}
Useful commands
- To debug natively:
$ go install # <- do once
$ go run *.go
- To build natively:
$ go build
$ ./GraphBasedServer # <- run the built executable
- To build docker image
$ ./build.sh
- To run docker image locally (for debug)
$ ./debug.sh
- To deploy docker image
$ ./deploy.sh