Giter Club home page Giter Club logo

fullstack-js-training's Introduction

Fullstack JS Training

A simple blog-like / forum project, inspired by the one for the Rails tutorial. Its goal is to train/refamiliarize me with popular web development frameworks in node.js. Currently, it uses an express API and two front-ends : one in Vue.js and the other in React.

Screenshot

Installation

This project uses :

  • Node.js 16.4
  • Sqlite 3

Packages must be installed for each subfolder, eg :

> cd api
> yarn

In order to be able to launch the API a blog-dev.sqlite3 database must be created in the api/ folder (as well as a blog-test.sqlite3 for running tests).

Usage

One API must be launched (currently on port 3000), then a client can be served and interacted with.

> cd api
> yarn start
// In another shell
> cd client-vue
> yarn serve

Source code

The project is a very basic blogging/forum app. It has a list of users that can make posts. The main idea was to have a basic CRUD structure.

All projects use eslint for linting and prettier for code formatting. I also decided to try out the Conventional Commits convention for this project.

API

For the moment there is only one API, my main focus was to train with front-end frameworks so I'm not sure whether I'll make any alternative version.

It uses Express and Sequelize with SQLite. I chose Sequelize because it seems to be very popular and I hadn't ever tried it so far. Now that I have, I would probably choose another one if I had to make a project (I liked Objection and although I haven't tried it yet I've heard good things about TypeORM). SQLite3 was chosen for its ease of use, any SQL would have worked (since my main goal was to test Sequelize).

The next time I make a node API I might try a fully-fledged out framework instead, like NestJS or AdonisJS.

Architecture

I decided to switch from MVC to a module/component architecture similar to the one described in this blog post. For the code, I was heavily inspired by n9-node-micro and n9-micro-starter.

I find that it makes more sense for the different files to be organized by concern rather than category in an API project. The model, controller, service and route files of a database table will be far more interconnected one with another than with those of external tables. Having an explicit mention of a file's type in its name (e.g. users.controller.js) also makes searching for them a lot easier.

This might cause a few issues with the sequelize-cli scaffolder since it seems to assume an MVC structure, but I think it's worth it.

Tests

Having already used Mocha + Chai and AVA in the past I decided to try Jest this time around. I also use factory-girl to avoid bloating end-to-end tests with database initialization or using redundant seeders which can make it hard to know exactly what is being tested.

Front-End

All the front-ends use Axios to make requests to the API and Bulma as a CSS framework (with a custom theme from bulmaswatch).

Tests

The front-ends use the same e2e test suite thanks to the awesome Cypress.io.

In order to run these you need to have the api running as well as the front you want to test. Then you have to run cypress with the correct base url env variable (i.e. yarn cypress:react or yarn cypress:vue). I'll make the front ends read their port from an env file at some point, this way restarting Cypress won't be required (although the current running front will have to be shutdown and the new one started, so there'll still be some wait time).

Vue

The Vue client is made with Vue 3, Vue Router, Vuex and VeeValidate.

React

The React client is made with React 17, React Router Dom, Redux Toolkit and React Hook Forms.

Angular

The Angular client is made with Angular 12. Unfortunately Angular 12 doesn't support Node v16 for the moment, so the client-angular directory uses Node v14.17 thanks to nvm instead.

fullstack-js-training's People

Contributors

ashtrail 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.