Skip to content

Commit

Permalink
refactor: merge packages
Browse files Browse the repository at this point in the history
 - decided to merge the api and core packages together. Initially I wanted
   separate packages for integration types, but looking at the code, it seems
   most code is shared, so there is little benefit to separation, especially
   since i'm assuming consumers will be tree shaking.
 - Added api and func integrations and a core folder.
  • Loading branch information
refactorthis committed Aug 20, 2024
1 parent 51f00fc commit 46734d6
Show file tree
Hide file tree
Showing 54 changed files with 11,432 additions and 4,064 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.workingDirectories": [{ "pattern": "./examples/**" }, { "pattern": "./packages/*" }],
"eslint.workingDirectories": [{ "pattern": "./examples/**" }, { "pattern": "./package/*" }],
"editor.stickyScroll.enabled": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
Expand Down
33 changes: 29 additions & 4 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,42 @@ pnpm test

## Repository layout

funcy is architected as a monorepo using a pnpm workspace.
funcy is architected as a single package.

- /packages/core - core funcy concerns
- /packages/api - funcy usage for building APIs using AWS Api Gateway
- /src/core - core funcy concerns
- /src/integrations - various integrations for building services using funcy
- /test - test helpers and mocks
- /examples - example projects showing the use of funcy
- /docs - github pages site

## Making a change

- Ensure you have forked the public repository and made your changes in a branch on your local fork.
- All changes must have corresponding test coverage in the same commit.
- All commits should be following the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) standard.
- Run all tests and typecheck locally again before raising a PR.
- Raise the PR to the main repository, requesting review from a core contributor.

## Documentation

If your changes involve new features or modifications to existing functionality, please update the relevant documentation. This includes:

- Inline code comments
- README.md files
- API documentation (if applicable)
- Update examples in the `/examples` directory if necessary

## Commit Messages

We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. Please ensure your commit messages are structured as follows:

```
<type>[optional scope]: <description>
<body>
[optional footer(s)]
```

## Code Style and Linting

We use ESLint and Prettier to maintain consistent code style. Before submitting a pull request, please ensure your code passes the linting and formatting checks.
Binary file modified docs/static/example-autocomplete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/static/example-strongly-typed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/sst-api/packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vitest": "^1.5.0"
},
"dependencies": {
"@funcy/api": "link:../../../../packages/api",
"@rt/funcy": "link:../../../../",
"zod": "^3.22.4"
}
}
6 changes: 3 additions & 3 deletions examples/sst-api/packages/functions/src/lambda.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { api, res } from '@funcy/api'
import { func } from '@refactorthis/funcy'

export const handler = api({
export const handler = func({
handler: async () => {
return res.ok(`Hello world. The time is ${new Date().toISOString()}`)
return `Hello world. The time is ${new Date().toISOString()}`
},
})
2 changes: 1 addition & 1 deletion examples/sst-api/packages/functions/src/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from 'zod'

// TODO generate this using zod-to-openapi
// NOTE this can be generated using zod-to-openapi

export const GetTodoPath = z.object({
id: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion examples/sst-api/packages/functions/src/todo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Todo } from '@sst-api/core/todo'
import { api, res } from '@funcy/api'
import { api, res } from '@refactorthis/funcy'
import { CreateTodoRequest, GetTodoPath, ListQuery, ListTodoResponse, TodoResponse } from './models'

export const create = api({
Expand Down
3 changes: 2 additions & 1 deletion examples/sst-api/packages/functions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"module": "esnext",
"moduleResolution": "node",
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"paths": {
"@sst-api/core/*": ["../core/src/*"],
"@funcy/api/*": ["../../../../packages/api/src/*"]
"@refactorthis/funcy": ["../../../../package"]
}
}
}
Loading

0 comments on commit 46734d6

Please sign in to comment.