Skip to content

otooooooooooooooooo/guess-it

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Project author - © Otar Kalandadze

Description

Api of the guessing based game just for web backend portfolio

Installation

$ npm install

Running the app

# local (generates typedoc files too)
$ npm run start

# watch mode
$ npm run start:watch

# production mode
$ npm run build && npm run start:prod

Test (Unit tests are not set up)

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Application flow: (Frontend prototype is available on /public endpoint)

  • (optional) Create room with POST request on endpoint /rooms and receive the room key

  • Join room by opening websocket (using socket.io) on namespace /rooms?key=keyReceivedFromApiOrFriend&username=optionalUsername. If an error is occurred during connection, connection error is emitted and connection is closed from server.

  • Listen to websocket events to receive your credentials (used to submit word guesses and adding custom words) and keep updated with current game state.

  • Mark yourself ready by sending PUT request on endpoint /rooms/ready. (Game will not start until all players are marked ready before each game)

  • (optional) If custom word mode is active, add custom words with POST request on endpoint /rooms/word (Game will not start if no custom words are provided)

  • (optional) To try and guess the word, submit guess with POST request on endpoint /rooms/guess

Documentation

See detailed HTTP documentation in swagger (Will be available on /swagger address when application is running)

See detailed events information (names and payload types) on /typedoc/modules/rooms_helpers_rooms_events.html when application is running and typedoc files have been generated in source code ./src/rooms/helpers/rooms.events.ts

See sample client application on /public address when application is running.

Prerequisite

Api uses Serpapi for fetching images from Google. So api key will be needed in configuration. You can generate it yourself for free (100 queries = 100games) by registering on Serpapi.

Configuration

App configuration is specified in .env file:

  • PORT - number(defaults to 3000)
  • CORS - boolean(defaults to false)
  • API_KEY - string(API key for Serpapi)

Credits

Game words list copied from engichang1467/word-pictionary-list