faucet-server-app 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/api/index.d.ts +24 -0
- package/dist/esm/api/index.d.ts.map +1 -1
- package/dist/esm/api/index.js +49 -11
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/chains.d.ts +303 -236
- package/dist/esm/chains.d.ts.map +1 -1
- package/dist/esm/chains.js +106 -1
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/config.d.ts +6 -0
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +28 -0
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/env.d.ts +1 -0
- package/dist/esm/env.d.ts.map +1 -1
- package/dist/esm/env.js.map +1 -1
- package/dist/esm/index.d.ts +49 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/index.ts +50 -11
- package/src/chains.ts +138 -1
- package/src/config.ts +37 -0
- package/src/env.ts +5 -0
- package/src/index.ts +1 -1
- package/dist/esm/api/captcha.d.ts +0 -38
- package/dist/esm/api/captcha.d.ts.map +0 -1
- package/dist/esm/api/captcha.js +0 -44
- package/dist/esm/api/captcha.js.map +0 -1
- package/dist/esm/api/claim.d.ts +0 -2
- package/dist/esm/api/claim.d.ts.map +0 -1
- package/dist/esm/api/claim.js +0 -2
- package/dist/esm/api/claim.js.map +0 -1
- package/dist/esm/api/dummy.d.ts +0 -28
- package/dist/esm/api/dummy.d.ts.map +0 -1
- package/dist/esm/api/dummy.js +0 -17
- package/dist/esm/api/dummy.js.map +0 -1
package/src/chains.ts
CHANGED
|
@@ -51,7 +51,22 @@ export function getChainConfig(env: Env, chainId: number): ChainConfigLookup {
|
|
|
51
51
|
if (!value) {
|
|
52
52
|
return {status: 'not-configured'};
|
|
53
53
|
}
|
|
54
|
+
const parsed = parseChainEntry(value);
|
|
55
|
+
if (parsed.status !== 'ok') {
|
|
56
|
+
return parsed;
|
|
57
|
+
}
|
|
58
|
+
return {status: 'ok', config: {chainId, ...parsed.entry}};
|
|
59
|
+
}
|
|
54
60
|
|
|
61
|
+
export type ChainEntry = {amount: bigint; rpcUrl: string};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Parses the `<amount_in_wei>:<rpc_endpoint>` value shared by CHAIN_<id> and
|
|
65
|
+
* CHAIN_FROM_NODE.
|
|
66
|
+
*/
|
|
67
|
+
export function parseChainEntry(
|
|
68
|
+
value: string,
|
|
69
|
+
): {status: 'ok'; entry: ChainEntry} | {status: 'invalid'; details: string} {
|
|
55
70
|
const colonIndex = value.indexOf(':');
|
|
56
71
|
if (colonIndex === -1) {
|
|
57
72
|
return {
|
|
@@ -81,7 +96,129 @@ export function getChainConfig(env: Env, chainId: number): ChainConfigLookup {
|
|
|
81
96
|
return {status: 'invalid', details: `amount must be greater than zero`};
|
|
82
97
|
}
|
|
83
98
|
|
|
84
|
-
return {status: 'ok',
|
|
99
|
+
return {status: 'ok', entry: {amount, rpcUrl}};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* CHAIN_FROM_NODE=<amount_in_wei>:<rpc_endpoint>: a chain whose id is whatever
|
|
104
|
+
* the node at that endpoint reports, for a local dev chain whose id is chosen
|
|
105
|
+
* when it starts. See docs/specs/follow-the-dev-chain.md.
|
|
106
|
+
*/
|
|
107
|
+
export function getFollowedChainEntry(
|
|
108
|
+
env: Env,
|
|
109
|
+
):
|
|
110
|
+
| {status: 'ok'; entry: ChainEntry}
|
|
111
|
+
| {status: 'not-configured'}
|
|
112
|
+
| {status: 'invalid'; details: string} {
|
|
113
|
+
const value = env.CHAIN_FROM_NODE;
|
|
114
|
+
if (value === undefined || value.trim() === '') {
|
|
115
|
+
return {status: 'not-configured'};
|
|
116
|
+
}
|
|
117
|
+
return parseChainEntry(value);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// A local node answers in milliseconds; failing fast keeps a request for an id
|
|
121
|
+
// the faucet does not serve from hanging on a node that is down.
|
|
122
|
+
const FOLLOW_TIMEOUT_MS = 5000;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Asks the followed node for its chain id. No cache: the node can be restarted
|
|
126
|
+
* under a new id at any time, and a stale id would send a claim to a chain
|
|
127
|
+
* that is not the one the caller named.
|
|
128
|
+
*/
|
|
129
|
+
export async function readFollowedChainId(entry: ChainEntry): Promise<number> {
|
|
130
|
+
return getFollowClient(entry.rpcUrl).getChainId();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getFollowClient(rpcUrl: string) {
|
|
134
|
+
return createPublicClient({
|
|
135
|
+
transport: http(rpcUrl, {retryCount: 0, timeout: FOLLOW_TIMEOUT_MS}),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type ResolvedChain = {
|
|
140
|
+
config: ChainConfig;
|
|
141
|
+
// true when the chain is served through CHAIN_FROM_NODE: its state is then
|
|
142
|
+
// keyed by chain identity, see getChainStateKey
|
|
143
|
+
followed: boolean;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type ChainLookup =
|
|
147
|
+
| {status: 'ok'; chain: ResolvedChain}
|
|
148
|
+
| {status: 'not-configured'}
|
|
149
|
+
| {status: 'invalid'; details: string}
|
|
150
|
+
| {status: 'unreachable'; details: string};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The chain a request names: a CHAIN_<id> line first (explicit configuration
|
|
154
|
+
* beats discovery), else the followed node when it reports that id.
|
|
155
|
+
*/
|
|
156
|
+
export async function resolveChain(
|
|
157
|
+
env: Env,
|
|
158
|
+
chainId: number,
|
|
159
|
+
): Promise<ChainLookup> {
|
|
160
|
+
const configured = getChainConfig(env, chainId);
|
|
161
|
+
if (configured.status === 'ok') {
|
|
162
|
+
return {
|
|
163
|
+
status: 'ok',
|
|
164
|
+
chain: {config: configured.config, followed: false},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (configured.status === 'invalid') {
|
|
168
|
+
return configured;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const followed = getFollowedChainEntry(env);
|
|
172
|
+
if (followed.status === 'not-configured') {
|
|
173
|
+
return {status: 'not-configured'};
|
|
174
|
+
}
|
|
175
|
+
if (followed.status === 'invalid') {
|
|
176
|
+
return {
|
|
177
|
+
status: 'invalid',
|
|
178
|
+
details: `CHAIN_FROM_NODE: ${followed.details}`,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let nodeChainId: number;
|
|
183
|
+
try {
|
|
184
|
+
nodeChainId = await readFollowedChainId(followed.entry);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
return {
|
|
187
|
+
status: 'unreachable',
|
|
188
|
+
details: err instanceof Error ? err.message : String(err),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (nodeChainId !== chainId) {
|
|
192
|
+
return {status: 'not-configured'};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
status: 'ok',
|
|
196
|
+
chain: {config: {chainId, ...followed.entry}, followed: true},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The key a chain's rows (Claims, ChainLocks) are stored under.
|
|
202
|
+
*
|
|
203
|
+
* A CHAIN_<id> entry keeps the bare id, as it always has. A followed chain is
|
|
204
|
+
* keyed by its identity, the id AND block 0's hash: a dev chain can be reset
|
|
205
|
+
* on the same id, and its rate limits and above all its last nonce must not
|
|
206
|
+
* carry over (a nonce from the old chain would be one the new chain never
|
|
207
|
+
* reaches). Read on EVERY request, before the lock and before the nonce: a
|
|
208
|
+
* cached hash would still be the old chain's on the first claim after a reset.
|
|
209
|
+
*/
|
|
210
|
+
export async function getChainStateKey(chain: ResolvedChain): Promise<string> {
|
|
211
|
+
const id = String(chain.config.chainId);
|
|
212
|
+
if (!chain.followed) {
|
|
213
|
+
return id;
|
|
214
|
+
}
|
|
215
|
+
const genesis = await getFollowClient(chain.config.rpcUrl).getBlock({
|
|
216
|
+
blockNumber: 0n,
|
|
217
|
+
});
|
|
218
|
+
if (!genesis.hash) {
|
|
219
|
+
throw new Error('the node returned no hash for block 0');
|
|
220
|
+
}
|
|
221
|
+
return `${id}:${genesis.hash.toLowerCase()}`;
|
|
85
222
|
}
|
|
86
223
|
|
|
87
224
|
export function getViemChain(config: ChainConfig): Chain {
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {getBigIntEnv, getCooldowns, type Env} from './env.js';
|
|
2
2
|
import {checkArbitraryCallsConfig, type ConfigIssues} from './calls.js';
|
|
3
|
+
import {getFollowedChainEntry, readFollowedChainId} from './chains.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Every configuration check the server can make without touching the network,
|
|
@@ -29,5 +30,41 @@ export function checkConfig(env: Env): ConfigIssues {
|
|
|
29
30
|
issues.errors.push(cooldowns.details);
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const followed = getFollowedChainEntry(env);
|
|
34
|
+
if (followed.status === 'invalid') {
|
|
35
|
+
issues.errors.push(
|
|
36
|
+
`CHAIN_FROM_NODE must be <amount_in_wei>:<rpc_endpoint>, ${followed.details}`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return issues;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Asks the node CHAIN_FROM_NODE follows for its id, once, for the start up
|
|
45
|
+
* log. An unreachable node is a warning, not an error: a dev stack starts the
|
|
46
|
+
* node beside the faucet, and the id is read again on every request anyway.
|
|
47
|
+
*/
|
|
48
|
+
export async function probeFollowedChain(env: Env): Promise<ConfigIssues> {
|
|
49
|
+
const issues: ConfigIssues = {errors: [], warnings: [], info: []};
|
|
50
|
+
const followed = getFollowedChainEntry(env);
|
|
51
|
+
if (followed.status !== 'ok') {
|
|
52
|
+
return issues;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const chainId = await readFollowedChainId(followed.entry);
|
|
56
|
+
const shadowed = env[`CHAIN_${chainId}` as `CHAIN_${string}`];
|
|
57
|
+
issues.info.push(
|
|
58
|
+
shadowed
|
|
59
|
+
? `CHAIN_FROM_NODE: the node reports chain ${chainId}, which a CHAIN_${chainId} line configures: that line wins`
|
|
60
|
+
: `CHAIN_FROM_NODE: following the node, which reports chain ${chainId}`,
|
|
61
|
+
);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
issues.warnings.push(
|
|
64
|
+
`CHAIN_FROM_NODE: the node is not reachable yet (${
|
|
65
|
+
err instanceof Error ? err.message.split('\n')[0] : String(err)
|
|
66
|
+
}); its chain id is read on every request, so it is followed once it is up`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
32
69
|
return issues;
|
|
33
70
|
}
|
package/src/env.ts
CHANGED
|
@@ -26,6 +26,11 @@ export type Env = {
|
|
|
26
26
|
ENABLE_ARBITRARY_CALLS?: string;
|
|
27
27
|
// Absolute gas limit granted to an arbitrary call, whatever the budget says.
|
|
28
28
|
MAX_CALL_GAS?: string;
|
|
29
|
+
// CHAIN_FROM_NODE=<amount>:<rpc_endpoint>: serve whatever chain id the node
|
|
30
|
+
// at that endpoint reports, for a local dev chain whose id is chosen when it
|
|
31
|
+
// starts. A CHAIN_<id> line for the same id wins. Its rows are keyed by chain
|
|
32
|
+
// identity (id and block 0's hash), see docs/specs/follow-the-dev-chain.md
|
|
33
|
+
CHAIN_FROM_NODE?: string;
|
|
29
34
|
// Dynamic env variables: CHAIN_<CHAIN_ID>=<amount>:<rpc_endpoint> for chain config
|
|
30
35
|
[key: `CHAIN_${string}`]: string | undefined;
|
|
31
36
|
// CALL_ALLOWLIST_<CHAIN_ID>=<contract>:<selector>,<selector>;<contract>:...
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type {
|
|
|
31
31
|
ConfigIssues,
|
|
32
32
|
GasPlan,
|
|
33
33
|
} from './calls.js';
|
|
34
|
-
export {checkConfig} from './config.js';
|
|
34
|
+
export {checkConfig, probeFollowedChain} from './config.js';
|
|
35
35
|
export {parseChainId} from './chains.js';
|
|
36
36
|
export type {ChainConfig} from './chains.js';
|
|
37
37
|
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ServerOptions } from '../types.js';
|
|
2
|
-
import { Env } from '../env.js';
|
|
3
|
-
export declare function getCaptchaAPI<CustomEnv extends Env>(options: ServerOptions<CustomEnv>): import("hono/hono-base").HonoBase<import("hono/utils/types").IfAnyThenEmptyObject<{
|
|
4
|
-
Bindings: CustomEnv;
|
|
5
|
-
} extends infer T ? T extends {
|
|
6
|
-
Bindings: CustomEnv;
|
|
7
|
-
} ? T extends import("hono").Env ? import("hono").Env extends T ? {} : T : T : never : never> & {}, {
|
|
8
|
-
"/verify": {
|
|
9
|
-
$post: {
|
|
10
|
-
input: {};
|
|
11
|
-
output: "hello world";
|
|
12
|
-
outputFormat: "text";
|
|
13
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
14
|
-
} | {
|
|
15
|
-
input: {};
|
|
16
|
-
output: {
|
|
17
|
-
error: string;
|
|
18
|
-
};
|
|
19
|
-
outputFormat: "json";
|
|
20
|
-
status: 500;
|
|
21
|
-
} | {
|
|
22
|
-
input: {};
|
|
23
|
-
output: {
|
|
24
|
-
error: string;
|
|
25
|
-
};
|
|
26
|
-
outputFormat: "json";
|
|
27
|
-
status: 400;
|
|
28
|
-
} | {
|
|
29
|
-
input: {};
|
|
30
|
-
output: {
|
|
31
|
-
error: string;
|
|
32
|
-
};
|
|
33
|
-
outputFormat: "json";
|
|
34
|
-
status: 401;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}, "/", "/verify">;
|
|
38
|
-
//# sourceMappingURL=captcha.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../../src/api/captcha.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AA8B9B,wBAAgB,aAAa,CAAC,SAAS,SAAS,GAAG,EAClD,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC;cAED,SAAS;;cAAT,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA4BzC"}
|
package/dist/esm/api/captcha.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import { setup } from '../setup.js';
|
|
3
|
-
const PROSOPO_VERIFY_ENDPOINT = 'https://api.prosopo.io/siteverify';
|
|
4
|
-
async function verifyProsopoCaptcha(token, secret) {
|
|
5
|
-
const body = {
|
|
6
|
-
token,
|
|
7
|
-
secret,
|
|
8
|
-
};
|
|
9
|
-
const response = await fetch(PROSOPO_VERIFY_ENDPOINT, {
|
|
10
|
-
method: 'POST',
|
|
11
|
-
headers: {
|
|
12
|
-
'Content-Type': 'application/json',
|
|
13
|
-
},
|
|
14
|
-
body: JSON.stringify(body),
|
|
15
|
-
});
|
|
16
|
-
const result = (await response.json());
|
|
17
|
-
return result.verified === true;
|
|
18
|
-
}
|
|
19
|
-
export function getCaptchaAPI(options) {
|
|
20
|
-
const app = new Hono()
|
|
21
|
-
.use(setup({ serverOptions: options }))
|
|
22
|
-
.post('/verify', async (c) => {
|
|
23
|
-
const config = c.get('config');
|
|
24
|
-
const env = config.env;
|
|
25
|
-
const secret = env.PROSOPO_SITE_PRIVATE_KEY;
|
|
26
|
-
if (!secret) {
|
|
27
|
-
return c.json({ error: 'PROSOPO_SITE_PRIVATE_KEY not configured' }, 500);
|
|
28
|
-
}
|
|
29
|
-
const body = await c.req.json();
|
|
30
|
-
const token = body.token;
|
|
31
|
-
if (!token) {
|
|
32
|
-
return c.json({ error: 'Missing token' }, 400);
|
|
33
|
-
}
|
|
34
|
-
const verified = await verifyProsopoCaptcha(token, secret);
|
|
35
|
-
if (verified) {
|
|
36
|
-
return c.text('hello world');
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return c.json({ error: 'Captcha verification failed' }, 401);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return app;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=captcha.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../../src/api/captcha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAGlC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAOpE,KAAK,UAAU,oBAAoB,CAClC,KAAa,EACb,MAAc;IAEd,MAAM,IAAI,GAAG;QACZ,KAAK;QACL,MAAM;KACN,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uBAAuB,EAAE;QACrD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;SAClC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC1B,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAC;IACzD,OAAO,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAC5B,OAAiC;IAEjC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAyB;SAC3C,GAAG,CAAC,KAAK,CAAC,EAAC,aAAa,EAAE,OAAO,EAAC,CAAC,CAAC;SACpC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAEvB,MAAM,MAAM,GAAG,GAAG,CAAC,wBAAwB,CAAC;QAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,yCAAyC,EAAC,EAAE,GAAG,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAmB,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,OAAO,CAAC,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE3D,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,6BAA6B,EAAC,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC,CAAC,CAAC;IAEJ,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/dist/esm/api/claim.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/api/claim.ts"],"names":[],"mappings":""}
|
package/dist/esm/api/claim.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../../src/api/claim.ts"],"names":[],"mappings":""}
|
package/dist/esm/api/dummy.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ServerOptions } from '../types.js';
|
|
2
|
-
import { Env } from '../env.js';
|
|
3
|
-
export declare function getDummyAPI<CustomEnv extends Env>(options: ServerOptions<CustomEnv>): import("hono/hono-base").HonoBase<import("hono/utils/types").IfAnyThenEmptyObject<{
|
|
4
|
-
Bindings: CustomEnv;
|
|
5
|
-
} extends infer T ? T extends {
|
|
6
|
-
Bindings: CustomEnv;
|
|
7
|
-
} ? T extends import("hono").Env ? import("hono").Env extends T ? {} : T : T : never : never> & {}, {
|
|
8
|
-
"/": {
|
|
9
|
-
$get: {
|
|
10
|
-
input: {};
|
|
11
|
-
output: "hello world";
|
|
12
|
-
outputFormat: "text";
|
|
13
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
} & {
|
|
17
|
-
"/setup": {
|
|
18
|
-
$get: {
|
|
19
|
-
input: {};
|
|
20
|
-
output: {
|
|
21
|
-
success: true;
|
|
22
|
-
};
|
|
23
|
-
outputFormat: "json";
|
|
24
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}, "/", "/setup">;
|
|
28
|
-
//# sourceMappingURL=dummy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dummy.d.ts","sourceRoot":"","sources":["../../../src/api/dummy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AAE9B,wBAAgB,WAAW,CAAC,SAAS,SAAS,GAAG,EAChD,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC;cAED,SAAS;;cAAT,SAAS;;;;;;;;;;;;;;;;;;;;;kBAazC"}
|
package/dist/esm/api/dummy.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import { setup } from '../setup.js';
|
|
3
|
-
export function getDummyAPI(options) {
|
|
4
|
-
const app = new Hono()
|
|
5
|
-
.use(setup({ serverOptions: options }))
|
|
6
|
-
.get('/', async (c) => {
|
|
7
|
-
const config = c.get('config');
|
|
8
|
-
const env = config.env;
|
|
9
|
-
// const storage = config.storage;
|
|
10
|
-
return c.text('hello world');
|
|
11
|
-
})
|
|
12
|
-
.get('/setup', async (c) => {
|
|
13
|
-
return c.json({ success: true });
|
|
14
|
-
});
|
|
15
|
-
return app;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=dummy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["../../../src/api/dummy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAGlC,MAAM,UAAU,WAAW,CAC1B,OAAiC;IAEjC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAyB;SAC3C,GAAG,CAAC,KAAK,CAAC,EAAC,aAAa,EAAE,OAAO,EAAC,CAAC,CAAC;SACpC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACvB,kCAAkC;QAClC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC,CAAC;SACD,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1B,OAAO,CAAC,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEJ,OAAO,GAAG,CAAC;AACZ,CAAC"}
|