Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/domitriusclark/sst-monorepo-example


https://github.com/domitriusclark/sst-monorepo-example

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

# Monorepo Template

A template to create a monorepo SST ❍ Ion project.

## Get started

1. Use this template to [create your own repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).

2. Clone the new repo.

```bash
git clone MY_APP
cd MY_APP
```

3. Rename the files in the project to the name of your app.

```bash
npx replace-in-file '/monorepo-template/g' MY_APP **/*.* --verbose
```

4. Deploy!

```bash
npm install
npx sst deploy
```

6. Optionally, enable [_git push to deploy_](https://ion.sst.dev/docs/console/#autodeploy).

## Usage

This template uses [npm Workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces). It has 3 packages to start with and you can add more it.

1. `core/`

This is for any shared code. It's defined as modules. For example, there's the `Example` module.

```ts
export module Example {
export function hello() {
return "Hello, world!";
}
}
```

That you can use across other packages using.

```ts
import { Example } from "@aws-monorepo/core/example";

Example.hello();
```

2. `functions/`

This is for your Lambda functions and it uses the `core` package as a local dependency.

3. `scripts/`

This is for any scripts that you can run on your SST app using the `sst shell` CLI and [`tsx`](https://www.npmjs.com/package/tsx). For example, you can run the example script using:

```bash
npm run shell src/example.ts
```

### Infrastructure

The `infra/` directory allows you to logically split the infrastructure of your app into separate files. This can be helpful as your app grows.

In the template, we have an `api.ts`, and `storage.ts`. These export the created resources. And are imported in the `sst.config.ts`.

---

Join the SST community over on [Discord](https://discord.gg/sst) and follow us on [Twitter](https://twitter.com/SST_dev).