Coder Social home page Coder Social logo

ganso's Introduction

ganso 🪿

Ganso (Portugeese word for goose) is part of the take home assignment for Goosechase software engineer position.

Prerequisites

  • Node.js: v18.16.0
  • npm: 9.5.1
  • Docker: 23.0.6

Getting started

Install dependencies:

npm install

Start local server:

npm run dev

The command above will start Docker, migrate the database, seed the database, and start the local server.

Testing

I am using vitest to test the application. Because I am using Docker for my PostgreSQL instance, there a few things to know before running the tests. To get it going, we need to run the docker compose up -d command, it is already done in the file scripts/test.sh, but it uses a bash script called wait-for-it.sh to wait for the database to be ready. In order to use this script on Mac the following command must be executed:

brew install coreutils && alias timeout=gtimeout

If homebrew is not available, just skip this part and run docker compose up -d manually and wait for it to be done.

To run the tests:

npm run test

The test command is basically the dev command, but it starts the server in background and then run the vitest, to kill the process in the port after the tests are done I am using kill-port package. It can be improved, but it gets the job done for now.

Technologies

For this project, in addition to the required technologies (Express, TypeScript, PostgreSQL), I chose to use Prisma for the convenience of setting up the database, declaring schemas and automatic generation of TypeScript types. I've also used Zod for validating schemas.

Postman collection

I've integrated this GitHub repository with Postman so I can test the API with the generated collection based on the Open API definition. It can be imported easily to the Postman app. There is a documentation on how to do it here.

Possible improvements

  • Better error messages. I have done a simple treatment for the errors I could find, it is not the best messages but they are clear about what went wrong;
  • Better testing flow. Starting Docker, starting local server, and running the tests can be heavy;
  • Integrate Swagger UI to serve a page with the Open API documentation could be useful;
  • The environment variables are in the .env file, which is not ignored. In a real world scenario this would not be included in the version control;
  • Some environment variables could be in the .env file too, like POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD;

ganso's People

Contributors

rfoel avatar

Stargazers

 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.