1
0
Fork 0
freesewing/sites/backend
Joost De Cock e4035b2509 chore: Re-structure workspaces, enforce build order
These are some changes in the way the monorepo is structured,
that are aimed at making it easier to get started.

There are two important changes:

**Multiple workspaces**

We had a yarn workspaces setup at `packages/*`. But our monorepo has
grown to 92 packages which can be overwhelming for people not familiar
with the package names.

To remedy this, I've split it into 4 different workspaces:

- `designs/*`: Holds FreeSewing designs (think patterns)
- `plugins/*`: Holds FreeSewing plugins
- `packages/*`: Holds other packages published on NPM
- `sites/*`: Holds software that is not published as an NPM package,
  such as our various websites and backend API

This should make it easier to find things, and to answer questions like
*where do I find the code for the plugins*.

**Updated reconfigure script to handle build order**

One problem when bootstrapping the repo is inter-dependencies between
packages. For example, building a pattern will only work once
`plugin-bundle` is built. Which will only work once all plugins in the
bundle or built. And that will only work when `core` is built, and so
on.

This can be frustrating for new users as `yarn buildall` will fail.
And it gets overlooked by seasoned devs because they're likely to have
every package built in their repo so this issue doesn't concern them.

To remedy this, we now have a `config/build-order.mjs` file and the
updated `/scripts/reconfigure.mjs` script will enforce the build order
so that things *just work*.
2022-06-16 17:11:31 +02:00
..
scripts chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
src chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
tests chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
.editorconfig chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
docker-compose.yml chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
Dockerfile chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
example.env chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
LICENSE chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
package.json chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
README.md chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00
run-mongo.sh chore: Re-structure workspaces, enforce build order 2022-06-16 17:11:31 +02:00

FreeSewing: A JavaScript library for made-to-measure sewing patterns

FreeSewing / backend

This is the backend for FreeSewing.org, our maker site.

Our backend is a REST API built with Express, using MongoDB as our database.

This API is required if you want to use your own instance of freesewing.org, in which case you have two ways to do so:

Run with docker

Using docker-compose

You can use docker-compose to spin up both the backend API and a mongo instance. Clone this repository, create a .env file (See Configuration), and then run:

docker-compose up

Your backend will now be available at http://localhost:3000

Using our docker image and your own database

If you just want the backend and provide your own mongo instance, you can run our docker image directly from the internet:

docker run --env-file .env --name fs_backend -d -p 3000:3000 freesewing/backend

Your backend will now be available at http://localhost:3000

Run from source

To run the backend from source, you'll need to clone this repository and intall dependencies.

git clone git@github.com:freesewing/backend
cd backend
npm install
npm install --global backpack-core

Note that we're installing backpack-core globally for ease-of-use

While developing, you can run:

npm run develop

And backpack will compile the backend, and spin it up. It will also watch for changes and re-compile every time. Handy!

If you want to run this in production, you should build the code:

npm run build

Then use something like PM2 to run it and keep it running.

Configuration

This backend can be configured with environment variables. They are detailed below.

Note:

If you're using docker (or docker-compose) you can use an environment file (See example.env).

If you're running from source, you need to set these manually, or via a script.

Variable Example Description
FS_BACKEND http://localhost:3000 URL on which the backend is hosted
FS_SITE http://localhost:8000 URL on which the frontend is hosted
FS_MONGO_URI mongodb://mongo/freesewing URL for the Mongo database
FS_ENC_KEY someLongAndComplexString Secret used for encryption of data at rest
FS_JWT_ISSUER freesewing.org The JSON Web Token issuer
FS_SMTP_HOST smtp.google.com SMTP relay through which to send outgoing emails
FS_SMTP_USER your.username@gmail.com SMTP relay username
FS_SMTP_PASS yourPasswordHere SMTP relay password
FS_GITHUB_CLIENT_ID clientIdForOathViaGithub Github client ID for signup/login via GitHub
FS_GITHUB_CLIENT_SECRET clientSecretForOathViaGithub Github client ID for signup/login via GitHub
FS_GOOGLE_CLIENT_ID clientIdForOathViaGoogle Google client ID for signup/login via Google
FS_GOOGLE_CLIENT_SECRET clientSecretForOathViaGoogle Google client ID for signup/login via Google

License

Copyright (c) 2019 Joost De Cock - Available under the MIT license.

See the LICENSE file for more details.