This is the API for our UoA Discord server registry, an online catalogue of various University of Auckland Discord servers.
We are not affiliated with the University of Auckland in any official capacity.
The production version of this API exists at https://registry.uoa-discords.com, and the documentation can be found here.
Dependencies:
- Node JS v16 or higher. Non-LTS and versions below 16 will probably work, but haven't been tested.
- pnpm, recommended but npm and yarn should still work fine.
You can easily get pnpm using:
npm i -g pnpmThis API uses MongoDB for persistent data storage and Discord OAuth for user authentication. This means you will need to set up:
- A MongoDB cluster and provide a connection URI for it (
mongodb+srv://...).- See setting up MongoDB.
- A Discord application and provide it's client ID and secret.
Next you can set up the repository from a terminal:
git clone https://github.com/UoA-Discords/server-registry-api.git server-registry-api
cd server-registry-api
pnpm install
cp config.example.json config.jsonFinally enter your Mongo URI and Discord client ID and secret into the config.json file you just created. There are a lot of other configuration options you can give to the API, and a JSON schema for all the values can be found here.
All done! You can now run scripts using pnpm <script name>, e.g. pnpm start. See the script reference below to get started.
startStarts API with hot-reloading enabled.buildCompiles API into JavaScript.lintMakes sure code follows style rules.typecheckMakes sure there are no type errors in the code.testRuns testing using Jest.check-allDoes linting, typechecking, and testing; note that this requires pnpm.
axiosMakes web requests easy.corsAllows configured websites to use the API.expressWeb framework the API uses.express-openapi-validatorEnsures endpoints match their documentation.express-rate-limitRate limits users of the API.jsonwebtokenHelps with user authorization and sessions.mongodbDatabase interface.swagger-ui-expressFramework for API documentation.
Remember to set the NODE_ENV environment variable to production if you want to start the API in production mode.
# Linux & Mac
export NODE_ENV=production
# Windows
$env:NODE_ENV = 'production'Afterwards you can compile the app using pnpm build and run it using node .
Contributions are always welcome, check out CONTRIBUTING.md to get started.
This API is licensed under the MIT license.
Trying out any operation in the api doc returns "Failed to fetch", how do I fix this?
Make sure your server (at the top of the page) is set to
registry.uoa-discords.com, since by default it looks for your development server which might not be running.
I've set up a local version of the API and logged in, but I don't seem to have any permissions?
You'll need to edit your user in MongoDB to give yourself every permission (value 127).
What are the possible statuses of a server in the registry?

