This is a starter back-end project that incorporates the following frameworks and libraries to build a OAuth 2 server
- Node + Express
- TypeScript (for Node)
- Docker deployment
- MySQL docker container
- Nunjucks for template rendering
- TypeORM for MySQL interfacing
- TypeDI for dependency injection
To get up and running
First, generate a
.env file, where variables such as
process.env.SECRET can be pulled from. See
.env.tmpl for the template.
cd docker && docker-compose up
npm run serve:dev and it should be up, hosted on
MySQL is on
127.0.0.1:33066 with username
root and password
root. Go in there, and you should see a user table as well as OAuth tables.
npm run test will test the DB connection. More testing is a
Existing endpoints and OAuth functionality
localhost:3000/oauth/login?client_id=clientIdAddedToClientTable&redirect_uri=redirectAddedToClientTable is set up to be a demo login page that returns an OAuth token.
redirect_uri params are required and read off of the matching
OAuthClient MySQL table columns, so just fill in an entry on that table and pass those values along in the URL
Additionally, you can check the
getUser endpoint by hitting the URLs such as
/user?email=myEmailThatIAddedToUserTable@domain.com, or POST a
Currently, password credentials are the only type of OAuth type supported, however it is designed to follow the spec for this implementation
Disclaimers and Acknowledgements
By running this project, you understand that...
- It is incomplete, including having some possibly commented-out code, and that you will not judge me for that. It should compile successfully though and demonstrate functionality in the basic features of API delivery and authentication.
- It is structured to serve what it could be one day, not what it is today.
Read more on CQRS
This project (particularly the CQRS pattern) was kickstarted with lots of help by Jason Raimondi