An API, written in TypeScript with Koa.js, for serving JSON files that are the JSON Schemas for various objects across my environment(s).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
4lch4 b831b3ec4b chore: executed prettier 1 month ago
.vscode chore: executed prettier 2 months ago
src chore: executed prettier 1 month ago
.dockerignore feat: added base files for functioning API 3 months ago
.drone.yml refactor(.drone.yml): moved update & restart step to new stage 2 months ago
.env.template feat: added base files for functioning API 3 months ago
.gitignore feat(.gitignore): updated entries 2 months ago
.npmrc feat: added base files for functioning API 3 months ago
.nvmrc refactor(.nvmrc): updated node version to 18 2 months ago
.prettierignore feat: added base files for functioning API 3 months ago
.prettierrc feat: added base files for functioning API 3 months ago
Dockerfile chore(Dockerfile): removed comment 2 months ago
LICENSE feat: added base files for functioning API 3 months ago
Makefile refactor(Makefile): fixed up a few scripts 2 months ago
OpenAPI-Spec.yml chore: executed prettier 1 month ago
README.md chore: executed prettier 2 months ago
jest.config.js feat: added base files for functioning API 3 months ago
package.json chore: executed prettier 1 month ago
pnpm-lock.yaml chore: executed prettier 2 months ago
questionnaire.json feat: updated package.json and questionnaire 2 months ago
tsconfig.json feat: added base files for functioning API 3 months ago

README.md

API Template

This template is to be used for bootstrapping a new API project w/ KoaJS. All of the dependencies that make up the service are listed below.

Dependencies

  • @4lch4/koa-oto
    • A library for responding to requests within the Koa framework.

  • @4lch4/koa-router-printer
    • A Koa middleware that outputs the routes registered to the application.

  • @4lch4/logger
    • A small utility for logging to console within NodeJS/TypeScript applications.

  • @koa/router
    • Router middleware for koa. Maintained by Forward Email and Lad.

  • dayjs
    • 2KB immutable date time library alternative to Moment.js with the same modern API.

  • koa
    • Expressive middleware for node.js using ES2017 async functions.

    • Built by the developers of Express.
  • koa-body
    • A Koa body parser middleware. Supports multipart, urlencoded and JSON request bodies.

  • koa-helmet
    • Security header middleware collection for Koa.

Dev Dependencies

  • @types/koa
    • TypeScript definitions for Koa.

  • @types/koa__router
  • @types/node
    • Provides TypeScript definitions for NodeJS v16 (LTS).

  • prettier
    • An opinionated code formatter that is used for formatting and linting.

  • ts-node
    • TypeScript execution environment and REPL for node.js, with source map support.

    • In other words, enables you to run a TypeScript file directly without first transpiling it.
      • e.g. ts-node ./src/index.ts
  • typescript
    • TypeScript is a language for application scale JavaScript development.

    • Ensures that I'm transpiling the codebase with the same version of TypeScript across devices.

Files

The following list explains the need/use of all the files that are in the repo:

NOTE: There is one exception, which is any index.ts files in a sub-directory. This is because they only export all of the files within said sub-directory, so they all do roughly the same thing but for their respective directory.

App Root Directory

Name/Path Description
.dockerignore Lists all the files to NOT add to the Docker image when building it.
.env.template A sample .env file that can be used to kickstart a new iteration of the project. Contains all the properties that are necessary for the API to function properly.
.gitignore A standard .gitignore file specifying which files not to include in the git repository.
.npmrc Used to provide npm config settings specifically for this repository/API.
.nvmrc Tells nvm which version of NodeJS to use for this repository/API.
.prettierignore Tells Prettier which files to ignore for all operations.
.prettierrc Provides the custom settings to the Prettier application.
Dockerfile A Dockerfile that can be used to package the API into a Docker image.
jest.config.js Provides the custom config settings to Jest, my test runner of choice.
LICENSE The body text of the license the repository is released under.
Makefile A "manifest" that when combined with GNU Make enable building, testing, and releasing the repository with simple commands.
package.json The standard node package.json file with all the pertinent information regarding the repository as an NPM package.
pnpm-lock.yaml The lock file for pnpm, my package manager of choice over Yarn or NPM.
questionnaire.json Provides all the necessary information to the Sindri-CLI to perform the final step of bootstrapping the project: Replace placeholder variables with project-specific values.
README.md A good ol' fashion README, which you're reading now 😊
tsconfig.json The config settings used by the TypeScript transpiler.

src Directory

The only individual file in the src directory is the index.ts file which is the main entrypoint to run the API server. Whenever the app is started, usually via npm start, then this script is what's run and the following is a list of all the steps performed:

  1. Import the getAppConfig method and Server class from ./src/lib/index.ts.
    1. The Server contains a private instance of the Koa package.
    2. Also provides some helper functions to help manage its lifecycle.