-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove fluture/sanctuary with neverthrow
- Loading branch information
1 parent
01dc187
commit 535ce9d
Showing
19 changed files
with
1,382 additions
and
8,754 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/bot/src/framework/discord/commands/create-character.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import type { ICommand } from '../types' | ||
import { resolve } from 'fluture' | ||
import { type ICommand } from '../types' | ||
import { okAsync } from 'neverthrow' | ||
|
||
export default { | ||
name: 'create-character', | ||
description: 'Creates a character', | ||
title: 'Create Character', | ||
execute: () => { | ||
return resolve('foo') | ||
return okAsync('foo') | ||
}, | ||
} as ICommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
import type { Rest } from './types' | ||
import { attemptP } from 'fluture' | ||
import fetch from 'node-fetch' | ||
import { type FetchPost, type Rest } from './types' | ||
import { fromAsyncThrowable } from 'neverthrow' | ||
|
||
export const get = (url: string) => () => { | ||
return fetch(url).then((r) => { | ||
export const get = (url: string) => () => | ||
fetch(url).then((r) => { | ||
if (r.ok) { | ||
return r.json() | ||
} | ||
}) | ||
} | ||
|
||
export const post = | ||
(url: string) => | ||
<R, T extends object>(b: T) => { | ||
return attemptP<string, R>(() => { | ||
return fetch(url, { | ||
method: 'post', | ||
body: JSON.stringify(b), | ||
headers: { 'Content-Type': 'application/json' }, | ||
}).then(async (r) => { | ||
if (r.ok) { | ||
return r.json() | ||
} else { | ||
return Promise.reject(await r.text()) | ||
} | ||
}) | ||
}) | ||
} | ||
const post = (url: string) => (b: object) => | ||
fetch(url, { | ||
method: 'post', | ||
body: JSON.stringify(b), | ||
headers: { 'Content-Type': 'application/json' }, | ||
}).then(async (r) => { | ||
if (r.ok) { | ||
return r.json() | ||
} else { | ||
return Promise.reject(await r.text()) | ||
} | ||
}) | ||
|
||
export const rest: Rest = { | ||
get, | ||
post, | ||
// TODO: This is probably a string or an error | ||
post: (url: string): FetchPost => | ||
fromAsyncThrowable(post(url), (e: string) => e), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters