Skip to content

Server | Home

Mitchell Mastromonaco edited this page Apr 17, 2020 · 14 revisions

Server setup

Installation

  1. Install dependencies: npm, postgresql (make sure md5 connexion are enabled).
  2. Change config file: server/config/default.json, to match port, username and password of your postgresql.
  3. Create an empty postgres database named as the value of the field database.database of the config file.
  4. Run npm install within the server file.
  5. Compile the server once using npm run tsc. There is a known error within the server on req.user.name. However, the code should have compiled if you have a file under the directory server/out/server/app/ by the name of www.js.
  6. Populate the database with npm run seeding-standard or npm run seeding-standard-windows if on a windows computer. This will ask you if you wish to erase your database. It will not change any other data within your computer, therefore, accept.
  7. If you have any images within your seeding, make sure that all your images, your preprocessings, and your thumbnails are added to the folder server/storage in folders labeled images, preprocessings, and thumbnails respectively.

Server start-up

Start the server with npm run dev (or npm run start-windows if on a windows computer).

Adding new files (controllers, repositories, and services)

In order to create new files, a few steps must be followed in order to further provide extensibility to the code.

If a controller is created, it must implement the interface abstractController so that the routing can be detected by the express middleware (for further information about routing see Endpoints).

If a repository is created, it must inject the ConnectionProvider in order to have access to the database.

No matter the file created, they must be added to the inversify.config.ts so that they may be correctly updated and compiled by the server.

For a controller:

container.bind<IController>(TYPES.Controller).to(YourNewController);

For a service or repository:

In the types.ts file:

YourNewServiceOrRepository: Symbol.for('YourNewServiceOrRepository')

In the inversify.config.ts file:

container.bind<YourNewServiceOrRepository>(TYPES.Controller).to(YourNewServiceOrRepository);

Documentation

Clone this wiki locally