-
Install PostgreSQL v12 from here
-
Install VSCode and these extensions:
- Vetur (syntax highlighting for .vue files)
- Debugger for Chrome (enables VSCode to connect with Chrome over the debug protocol, only if you want to use VSCode for debugging)
-
Install the Vue DevTools for Chrome (and Chrome if you don't have it)
-
Install latest NodeJS LTS version
-
Install the Vue-CLI tools (only really necessary if you want to modify the project's setup):
npm install -g @vue/cli -
Install all tools used throughout the project. Might take a while, get a beer while waiting.
cd project-dir npm install
| Command | Effect |
|---|---|
npm run dev-client |
Run the dev version of the frontend |
npm run dev-server |
Run the dev version of the server |
npm run test-server |
Run tests on the server code |
npm run build-client |
Build frontend for production |
npm run build-server |
Build server for production |
npm run lint |
Run linter |
npm run lint-autofix |
Run linter and autofix errors |
npm run db -- <command> |
A multi-purpose tool which manages interactions with the database. Run npm run db -- --help for a list of commands |
- Open the project dir in VSCode
- Run
npm run dev-clientin a terminal - Run
npm run dev-serverin a second terminal - Go to localhost:8080
- Change code, see the change applied in the browser immediately
- You can debug in Chrome or you can debug in VS Code by clicking Run (on the left top-level menu in VSCode) and then hit the Debug button. This will launch a separate Chrome window.
- When committing, the system will run a lint check and ask you to fix any issues
| Feature | Casing |
|---|---|
| Classes | PascalCase |
| Local Variables | camelCase |
| Function args | camelCase |
| Public Members | camelCase |
| Private Members | camelCase |
| Functions | camelCase |
| Constants | SCREAM_CASE |
-
Do NOT use
_for private fields. Vue has a variety of issues with members prefixed with$or_which make development much harder. -
Order class members in this order:
- public data members
- protected data members
- private data members
- public function members
- protected function members
- private function members
-
When a data class and a component class need to use similar names, add the
Componentsuffix to the component. Example:Commentis the data class,CommentComponentis the Component which renders a single comment. -
Add the suffix
Viewto any complete view. Always place them in the Views directory. -
When working with store (Vuex) data:
- Do NOT access directly store state. Create computed properties in your component which refer to it
- Do call directly store mutations/actions.
We use Vue on the client to build a SPA and Node/Express/PostgreSQL on the server. TypeScript is used throughout as the only programming language. Mocha + Chai are running our tests. The client and the server are to developed somewhat independently - they have their own tests, configurations, build systems, etc.
As much as possible is shared between the client and the backend. Keep it that way. Major differences are outlined below.
| Directory | Expect to find |
|---|---|
| src/client | client (frontend) code |
| src/logic | shared client & server code |
| src/server | server code |
| tsconfig.base.json | the tsconfig with common settings between client & server |
| tsconfig.json | the tsconfig for the client. It's in the root dir because of Vue-CLI limitations |
| src/server/tsconfig.json | the tsconfig for the server |
Alongside Vue, these Vue extensions are installed:
- Vuex - Vue's state management library. Vue's Flux. It's purpose is to be a heterogenous, global storage of variables used throughout the entire client side.
- Direct Vuex - A small open-source library which acts as a TypeScript-wrapper around Vuex
- Vue Router - Used for routing (history, back, forward, etc.)
- Vuetify - A popular UI framework
- Vue-CLI - This is the collection of Vue's tools. They are used everywhere on the client side to build, run dev server, install new vue plugins, etc.
The entire build / dev system is based on Vue-CLI. The tsconfig.json at the repo's root is the one used for the client. This is because Vue-CLI may not use any other config file :/.
- Express.js - Our HTTP server. It's only implemented at the most basic level. Currently, we have not implemented pretty much all performance and security options of Express.
- PostgreSQL is our database. To interact with it, we use the pg and pgtools modules and the ORM/SQLBuilder TypeORM. We only use the SQLBuilder part of it for architectural reasons. Never use the ActiveRecord/DataMapper patterns, always interact with the DB through building SQL queries.
- To access the RDMS, run pgAdmin and open http://localhost:57946/ in your browser.
The dev version of the build system is based on nodemon and ts-node. ts-node allows one to execute TypeScript without intermediate compilation (this allows us to greatly simplify the dev environment) and nodemon is a demon responsible for restarting the server whenever server code is changed.