-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lemonsqueezy): stub out userland APIs
- Loading branch information
1 parent
16f3868
commit 362055e
Showing
10 changed files
with
264 additions
and
80 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* pay hook | ||
* | ||
* @description :: A hook definition. Extends Sails by adding shadow routes, implicit actions, and/or initialization logic. | ||
* @docs :: https://sailsjs.com/docs/concepts/extending-sails/hooks | ||
*/ | ||
|
||
module.exports = function (sails) { | ||
return { | ||
defaults: { | ||
pay: { | ||
provider: 'default', | ||
providers: {} | ||
} | ||
}, | ||
/** | ||
* Runs when this Sails app loads/lifts. | ||
*/ | ||
initialize: async function () { | ||
sails.log.info('Initializing custom hook (`pay`)') | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
friendlyName: 'Checkout', | ||
|
||
description: 'Checkout pay.', | ||
|
||
inputs: {}, | ||
|
||
exits: {}, | ||
|
||
fn: async function (inputs) { | ||
// All done. | ||
sails.helpers.pay.checkout.with({}) | ||
sails.helpers.pay.charge.with({}) | ||
sails.helpers.pay.charge.with({ provider: 'lemonsqueezy' }) | ||
return | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports.pay = { | ||
providers: { | ||
default: { | ||
adapter: 'sails-lemonsqueezy' | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"include": ["api/**/*", "assets/js/**/*", "types/index.d.ts"], | ||
|
||
"compilerOptions": { | ||
"types": ["node"], | ||
"typeRoots": ["./types", "./node_modules/@types"], | ||
"lib": ["es2016"], | ||
// silences wrong TS error, we don't compile, we only typecheck | ||
"outDir": "./irrelevant/unused", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noEmitOnError": true, | ||
"noErrorTruncation": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["assets/js/*"] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,182 @@ | ||
interface Sails { | ||
log: LogMethod & LogObject | ||
models: { [modelName: string]: Model } | ||
helpers: Helper | ||
on(event: string, listener: (...args: any[]) => void): void | ||
off(event: string, listener: (...args: any[]) => void): void | ||
emit(event: string, ...args: any[]): void | ||
lift(cb?: (err: Error, sails: Sails) => void): Sails | ||
lower(cb?: (err?: Error) => void): void | ||
load(): Sails | ||
getVersion(): string | ||
inertia: Inertia | ||
wish: Wish | ||
hooks: Hook | ||
config: Config | ||
req: { | ||
ip: string | ||
} | ||
renderView: ( | ||
relPathToView: string, | ||
_options: Dictionary, | ||
optionalCb?: (err: Error | null, compiledHtml: string) => void | ||
) => Sails & Promise<string> | ||
intercept(callback: (err: Error) => Error): Sails & Promise<string> | ||
} | ||
|
||
interface Helper { | ||
passwords: { | ||
hashPassword: (password: string, strength?: number) => Promise<string> | ||
checkPassword: ( | ||
passwordAttempt: string, | ||
hashedPassword: string | ||
) => Promise<Sails> | ||
} | ||
strings: { | ||
random: (style?: 'url-friendly' | 'alphanumeric') => string | ||
uuid: () => string | ||
} | ||
mail: { | ||
send: { | ||
with: (params: EmailParams) => Promise<string> | ||
} | ||
} | ||
pay: { | ||
checkout: { | ||
with: (params: CheckoutParams) => Promise<string> | ||
} | ||
charge: { | ||
with: (params: CheckoutParams) => Promise<string> | ||
} | ||
} | ||
getUserInitials: (fullName: string) => string | ||
capitalize: (inputString: string) => string | ||
} | ||
interface EmailParams { | ||
mailer?: string | ||
to: string | ||
cc?: string | array<string> | ||
bcc?: string | array<string> | ||
subject?: string | ||
template?: string | ||
templateData?: object | ||
attachments?: EmailAttachment[] | ||
} | ||
interface EmailAttachment { | ||
filename: string | ||
content?: string | Buffer | NodeJS.ReadableStream | ||
path?: string | ||
href?: string | ||
httpHeaders?: { [key: string]: string } | ||
contentType?: string | ||
contentDisposition?: string | ||
cid?: string | ||
encoding?: string | ||
headers?: { [key: string]: string } | ||
raw?: string | ||
} | ||
|
||
interface Hook { | ||
inertia: Inertia | ||
pay: Pay | ||
} | ||
interface LogMethod { | ||
(...args: any[]): void | ||
} | ||
|
||
interface LogObject { | ||
info: LogMethod | ||
warn: LogMethod | ||
error: LogMethod | ||
debug: LogMethod | ||
silly: LogMethod | ||
verbose: LogMethod | ||
} | ||
|
||
interface Config { | ||
smtp: { | ||
transport?: 'smtp' | ||
host?: string | ||
port?: number | ||
encryption?: 'tls' | 'ssl' | ||
username: string | ||
password: string | ||
} | ||
google: { | ||
clientId: string | ||
clientSecret: string | ||
redirect: string | ||
} | ||
mail: { | ||
default: string | ||
mailers: { | ||
log: object | ||
smtp: { | ||
transport: 'smtp' | ||
host: string | ||
port: number | ||
encryption: 'tls' | 'ssl' | ||
username?: string | ||
password?: string | ||
} | ||
} | ||
from: { | ||
name: string | ||
address: string | ||
} | ||
} | ||
custom: Custom | ||
} | ||
|
||
interface Custom { | ||
baseUrl: string | ||
passwordResetTokenTTL: number | ||
emailProofTokenTTL: number | ||
rememberMeCookieMaxAge: number | ||
internalEmail: string | ||
verifyEmail: boolean | ||
} | ||
interface Wish { | ||
provider: (provider: string) => Wish | ||
redirect: () => string | ||
user: (code: string) => GoogleUser | GitHubUser | ||
} | ||
interface Inertia { | ||
share: (key: string, value?: any) => void | ||
render: ( | ||
component: string, | ||
props?: Record<string, any>, | ||
viewData?: Record<string, any> | ||
) => any | ||
flushShared: (key?: string) => void | ||
viewData: (key: string, value: any) => void | ||
getViewData: (key: string) => any | ||
setRootView: (newRootView: string) => void | ||
getRootView: () => string | ||
location: (path: string) => void | ||
} | ||
|
||
interface GoogleUser { | ||
id: string | ||
email: string | ||
verified_email: boolean | ||
name: string | ||
given_name: string | ||
family_name: string | ||
picture: string | ||
locale: string | ||
accessToken: string | ||
idToken: string | ||
} | ||
|
||
interface LoggedInUser { | ||
id: string | ||
fullName: string | ||
email: string | ||
initials?: string | ||
googleAvatarUrl?: string | ||
value: LoggedInUser | ||
} | ||
declare const sails: Sails | ||
|
||
declare const User |
This file was deleted.
Oops, something went wrong.