Giter VIP home page Giter VIP logo

code-sample-nestjs-schools-api's Introduction

Schools API Code Sample

A sample API to retrieve information about New Zealand schools, sourced from the Schools Directory on data.govt.nz.

Requirements

pnpm is my Node.js package manager of choice, and is the only requirement to run this. If you don't want to use this, but have npm installed, you can prefix all pnpm commands with npx, e.g. npx pnpm install - this will run pnpm via npm.

Getting Started

  1. Clone the repo locally
  2. Copy .env.example to .env
  3. Run pnpm install
  4. Run pnpm run start
  5. Visit http://localhost:3000/swagger#/ in your browser to view the Swagger UI

Design Choices

  • This is a code sample. It contains design choices I would like to showcase, not necessarily the exact choices I would make for any given project - that would depend on other factors.

  • I've split the codebase into a few Nest.js modules to break up different responsibilities. This is how I like to structure my Nest.js projects.

  • I've also split larger modules into three layers - application, domain, and infrastructure. These further break up the responsibilities within a module into application (HTTP), domain (core logic), and persistence (in this case, SQLite) concerns. I like to structure most projects with layers such as these.

  • I've skipped an ORM, as a demonstration of how I might approach more complex projects. I find ORMs can mix up domain logic and persistence logic, and only use them in certain use cases, such as simple CRUD apps.

  • I opted to use SQLite as a database, as there is one table with a minimal amount of data, and this makes the project very easy to run.

  • Since no database is required, I also opted to keep the project runnable with just Node.js/PNPM, rather than requiring docker. A docker setup would be trivial anyway.

  • Tests have been skipped. Nothing is particularly complex here, and tests would only be verifying trivial things that are mostly verified by TypeScript already.

code-sample-nestjs-schools-api's People

Contributors

tomha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.