Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .claude/CONVENTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Project Conventions

Rules that apply across all skills. Each SKILL.md references this file instead of repeating these.

---

## Scope

- **Stay inside the target package directory.** Do not read files outside of it unless explicitly told to.
- **Do not invent features.** Only document or test what source code confirms exists.

## Code Examples

- Use **TypeScript** in all code examples.
- Keep examples minimal — just enough to show the point, no boilerplate.

## Testing

### General Rules

- **Use Vitest** (`import from "vitest"`). The project already has it configured.
- **Test what WE wrote, not what third-party libraries do.** Ask: "Does this verify code our team wrote, or that a third-party library works?"
- **Name tests by behavior**, not implementation. GOOD: `"decorates instance with default documentation path"` BAD: `"line 23 sets routePrefix"`

### Mock Rules

- **Use real Fastify instances. Do NOT mock Fastify.** Plugins are side-effect functions — mocking the instance means testing nothing.
- **Do NOT mock base-library plugins** (e.g., `@fastify/swagger`, `@fastify/multipart`). The point of the integration layer tests is to catch breakage from dependency upgrades.
- Mock only our own modules (migrations, sub-plugins we authored).

### Cleanup

- **Always close Fastify instances in `afterEach`** to avoid resource leaks.

### Known Gotchas

These patterns have been validated in this monorepo. Follow them to avoid known pitfalls:

1. **`hasContentTypeParser("*")` returns false** even when a `*` catch-all parser is registered in Fastify 5. Use a behavioural test instead: inject a request with an unusual content-type and assert the status is not 415.
2. **Asserting `vi.fn()` plugin calls**: always include `expect.any(Function)` as the third argument — Fastify calls plugins as `plugin(fastify, options, done)`.
3. **`Readable.from(["string"])` emits strings, not Buffers.** `Buffer.concat` will throw. Use `Readable.from([Buffer.from("string")])` instead.
4. **Verify `@fastify/multipart`** with `fastify.hasContentTypeParser("multipart/form-data")`, not `getSchema("fileSchema")` — `sharedSchemaId` does not expose a schema via `fastify.getSchema`.

## Base Library Documentation

- **Do not repeat base library documentation in detail.** Link to their docs.
- **For doc links:** use the library's official docs URL. If unsure, use the npm page: `https://www.npmjs.com/package/{package-name}`.
- **List only the delta** for partial/modified passthroughs — what we change, not what we preserve.
4 changes: 1 addition & 3 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": [
"@commitlint/config-conventional"
]
"extends": ["@commitlint/config-conventional"]
}
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: "Test suite"

on:
push
on: push

jobs:
test:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
**/dist
**/*.log*
**/node_modules
**/skills
**/skills.old
.turbo
576 changes: 215 additions & 361 deletions CHANGELOG.md

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,64 @@
# @prefabs.tech/saas

A set of saas libraries by prefabs.tech.

## Packages
- @prefabs.tech/saas-fastify (https://www.npmjs.com/package/@prefabs.tech/saas-fastify)
- @prefabs.tech/saas-react (https://www.npmjs.com/package/@prefabs.tech/saas-react)

- @prefabs.tech/saas-fastify (https://www.npmjs.com/package/@prefabs.tech/saas-fastify)
- @prefabs.tech/saas-react (https://www.npmjs.com/package/@prefabs.tech/saas-react)

# Installation & Usage

## Install dependencies

Install dependencies recursively with this command

```bash
make install
```

## Build all packages

```bash
make build
```

## Lint code

```bash
make lint
```

## Typecheck code

```bash
make typecheck
```

## Test

```bash
make test
```

# Developing locally & testing

You can test these libraries locally without releasing using the `pnpm link` command. This allows your application to use the local version of the library instead of the published one. [More on pnpm link](https://pnpm.io/cli/link).

To link a library locally, run this command from the respective app directory:

```bash
pnpm link ./<path_to_libraries_monorepo>/packages/<library_name>
```

To unlink the library:

```bash
pnpm unlink ./<path_to_libraries_monorepo>/packages/<library_name>
```

## Troubleshooting
- Make sure that `package.json` and `pnpm-lock.yml` are synchronized.
- You may need to restart your apps before link and unlink to see the changes.
- All the libraries that defines or uses context has to be linked in order to link one libraries that use the context or defines it.

- Make sure that `package.json` and `pnpm-lock.yml` are synchronized.
- You may need to restart your apps before link and unlink to see the changes.
- All the libraries that defines or uses context has to be linked in order to link one libraries that use the context or defines it.
Loading
Loading