Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Update with latest libs (#16)
Browse files Browse the repository at this point in the history
* Prepare lib update

* api fixed

* Drop libs submodule

* all fixed

* all fixed

* all fixed
  • Loading branch information
patroza authored Sep 11, 2021
1 parent 9532aa6 commit 602ebfa
Show file tree
Hide file tree
Showing 66 changed files with 2,636 additions and 3,107 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

8 changes: 4 additions & 4 deletions .vscode/model.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
"GetRequest": {
"prefix": "gr",
"body": [
"export default class Request extends Get(\"/$1\")<Request>()({$2}) {}",
"export class Request extends Get(\"/$1\")<Request>()({$2}) {}",
""
],
"description": "Defines a GetRequest signature"
},
"DeleteRequest": {
"prefix": "dr",
"body": [
"export default class Request extends Delete(\"/$1\")<Request>()({$2}) {}",
"export class Request extends Delete(\"/$1\")<Request>()({$2}) {}",
""
],
"description": "Defines a DeleteRequest signature"
},
"PatchRequest": {
"prefix": "par",
"body": [
"export default class Request extends Patch(\"/$1\")<Request>()({$2}) {}",
"export class Request extends Patch(\"/$1\")<Request>()({$2}) {}",
""
],
"description": "Defines a PatchRequest signature"
},
"PutRequest": {
"prefix": "pur",
"body": [
"export default class Request extends Put(\"/$1\")<Request>()({$2}) {}",
"export class Request extends Put(\"/$1\")<Request>()({$2}) {}",
""
],
"description": "Defines a PutRequest signature"
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ TODO: Implement a Layer to demo replacing for example the persistence mechanism.
## Getting Started

From repo root:
- `git submodule update --init --recursive`
- `yarn`
- `yarn libs-fix` - this installs some npm bins to libs, do **not** run `yarn` inside the libs folder!
- `yarn dev`
- visit `http://localhost:3133`
- for api docs, visit: `http://localhost:3330/docs` or `http://localhost:3330/swagger`
Expand All @@ -34,16 +32,6 @@ Interesting bits are in:

You can interact via the included frontend project, the docs or swagger endpoint, Postman (by importing api/openapi.json), or go wild with `curl` if that's your thing ;-)

### A word on the libs submodule

While not ideal, I like developing the sample app and the libraries in tandem,
as such the easiest way to do this is not to have to deploy to NPM and update the packages every time the libs change.
I've tried many different setups, but the current one seems to tick most of the boxes (always a compromise).
The trick now is to have the libs node_modules/.bin installed (linked to root node_modules), but not the actual packages.
You have been warned :) Duplicate effect-ts packages etc will ruin your day!

Once the libs stabilise, we can switch to published npm packages.

### Postman

1. import [openapi.json](apps/api/openapi.json)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/Me/_routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as A from "@effect-ts/core/Collections/Immutable/Array"
import * as T from "@effect-ts/core/Effect"
import * as R from "@effect-ts-app/infra/express/schema/routing"
import * as R from "@effect-ts-app/infra/express/routing"

import { demandLoggedIn } from "@/middleware"

Expand Down
2 changes: 1 addition & 1 deletion apps/api/TaskLists/_routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as A from "@effect-ts/core/Collections/Immutable/Array"
import * as T from "@effect-ts/core/Effect"
import * as R from "@effect-ts-app/infra/express/schema/routing"
import * as R from "@effect-ts-app/infra/express/routing"

import { demandLoggedIn } from "@/middleware"

Expand Down
7 changes: 4 additions & 3 deletions apps/api/Tasks/Create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import * as T from "@effect-ts/core/Effect"
import * as Test from "@effect-ts/jest/Test"
import * as O from "@effect-ts-app/core/Option"
import { ReasonableString } from "@effect-ts-app/core/Schema"
import { TaskAudits, TaskEvents } from "@effect-ts-demo/todo-types/Task"

import { reasonableStringUnsafe, testUser } from "@/test.helpers"
import { testUser } from "@/test.helpers"

import { createTask_ } from "./Create"

Expand All @@ -18,7 +19,7 @@ it("returns domain events", () =>
listId: "inbox",
myDay: O.none,
isFavorite: false,
title: reasonableStringUnsafe("Test task"),
title: ReasonableString.unsafe("Test task"),
})

expect(events).toEqual([
Expand All @@ -32,7 +33,7 @@ it("adds an Audit on creation", () =>
listId: "inbox",
myDay: O.none,
isFavorite: false,
title: reasonableStringUnsafe("Test task"),
title: ReasonableString.unsafe("Test task"),
})

expect(task.auditLog[0]).toEqual(
Expand Down
2 changes: 1 addition & 1 deletion apps/api/Tasks/Create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default handle(Tasks.Create)((input) =>
})
)

export function createTask_(user: User, input: Tasks.Create.default) {
export function createTask_(user: User, input: Tasks.Create.CreateTaskRequest) {
const task = User.createTask._(user, input)

return tuple(
Expand Down
4 changes: 2 additions & 2 deletions apps/api/Tasks/Search.external.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as T from "@effect-ts/core/Effect"
import * as L from "@effect-ts/core/Effect/Layer"
import * as Test from "@effect-ts/jest/Test"
import * as HF from "@effect-ts-app/core/http/http-client-fetch"
import { PositiveInt } from "@effect-ts-app/core/Schema"
import { LiveApiConfig } from "@effect-ts-demo/todo-client/config"
import { searchWithFields } from "@effect-ts-demo/todo-client/Tasks/_custom"
import { positiveIntUnsafe } from "@effect-ts-demo/todo-client/test.helpers"
import fetch from "cross-fetch"

import { managedServer } from "@/test.setup"
Expand Down Expand Up @@ -36,7 +36,7 @@ it("works with partial call", () =>
T.gen(function* ($) {
const req = {
$select: ["id", "title"] as const,
$skip: positiveIntUnsafe(10),
$skip: PositiveInt.unsafe(10),
$count: true,
}

Expand Down
13 changes: 7 additions & 6 deletions apps/api/Tasks/Update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import * as T from "@effect-ts/core/Effect"
import * as Test from "@effect-ts/jest/Test"
import * as O from "@effect-ts-app/core/Option"
import { LongString, ReasonableString } from "@effect-ts-app/core/Schema"
import { User } from "@effect-ts-demo/todo-types/"
import { TaskAudits } from "@effect-ts-demo/todo-types/Task"
import { Attachment } from "@effect-ts-demo/todo-types/Task/shared"

import { longStringUnsafe, reasonableStringUnsafe, testUser } from "@/test.helpers"
import { testUser } from "@/test.helpers"

import { updateTask } from "./Update"

Expand All @@ -15,14 +16,14 @@ const { it } = Test.runtime()
const user = testUser()
const initialTask = user["|>"](
User.createTask({
title: reasonableStringUnsafe("hi"),
title: ReasonableString.unsafe("hi"),
})
)

it("changes the provided props", () =>
T.succeedWith(() => {
const [task, events] = initialTask["|>"](
updateTask({ title: reasonableStringUnsafe("ho") }, user.id)
updateTask({ title: ReasonableString.unsafe("ho") }, user.id)
)

expect(task.title).not.toBe(initialTask.title)
Expand Down Expand Up @@ -72,9 +73,9 @@ it("adds reminder to user", () =>
it("adds an Audit on file attachment added", () =>
T.succeedWith(() => {
const a = new Attachment({
fileName: reasonableStringUnsafe("abc.gif"),
url: longStringUnsafe("http://alabalbla/balbla/abc.gif"),
mimetype: reasonableStringUnsafe("application/gif"),
fileName: ReasonableString.unsafe("abc.gif"),
url: LongString.unsafe("http://alabalbla/balbla/abc.gif"),
mimetype: ReasonableString.unsafe("application/gif"),
})

const [task, events] = initialTask["|>"](
Expand Down
2 changes: 1 addition & 1 deletion apps/api/Tasks/_routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as A from "@effect-ts/core/Collections/Immutable/Array"
import * as T from "@effect-ts/core/Effect"
import * as R from "@effect-ts-app/infra/express/schema/routing"
import * as R from "@effect-ts-app/infra/express/routing"

import { demandLoggedIn } from "@/middleware"

Expand Down
Loading

0 comments on commit 602ebfa

Please sign in to comment.