mirror of https://github.com/sylv/micro.git
chore: fix build issues
This commit is contained in:
parent
89ff23edfd
commit
5ec8396a8b
|
@ -10,7 +10,7 @@
|
|||
"node": ">=16"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "tsup src/main.ts src/migrations/* --watch --clean --format esm --sourcemap --onSuccess \"node dist/main.js --inspect --inspect-brk\"",
|
||||
"watch": "tsup src/main.ts src/migrations/* --target node16 --watch --clean --format esm --sourcemap --onSuccess \"node dist/main.js --inspect --inspect-brk\"",
|
||||
"build": "rm -rf ./dist && ncc build src/main.ts -o dist --minify --transpile-only --v8-cache --no-source-map-register",
|
||||
"lint": "eslint src --fix --cache",
|
||||
"test": "vitest run"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { fileTypeFromBuffer } from 'file-type';
|
||||
import { isBinary } from 'istextorbinary';
|
||||
import * as mimeType from 'mime-types';
|
||||
import path from 'path';
|
||||
import type { PassThrough } from 'stream';
|
||||
|
||||
// @ts-expect-error see tsconfig.json/paths
|
||||
import { isBinary } from 'istextorbinary';
|
||||
|
||||
const DEFAULT_TYPE = 'application/octet-stream';
|
||||
// is-binary scans the first 1kb
|
||||
// file-type scans the first 4.2kb
|
||||
|
|
|
@ -11,45 +11,50 @@ import { migrate } from './migrate.js';
|
|||
import { AppModule } from './modules/app.module.js';
|
||||
import { HostGuard } from './modules/host/host.guard.js';
|
||||
|
||||
await migrate();
|
||||
async function bootstrap() {
|
||||
await migrate();
|
||||
|
||||
const logger = new Logger('bootstrap');
|
||||
const server = fastify({
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
maxParamLength: 500,
|
||||
bodyLimit: config.uploadLimit,
|
||||
logger: {
|
||||
level: 'trace',
|
||||
},
|
||||
});
|
||||
const logger = new Logger('bootstrap');
|
||||
const server = fastify({
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
maxParamLength: 500,
|
||||
bodyLimit: config.uploadLimit,
|
||||
});
|
||||
|
||||
const adapter = new FastifyAdapter(server as any);
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
|
||||
app.useGlobalGuards(new HostGuard());
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
forbidUnknownValues: true,
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
const adapter = new FastifyAdapter(server as any);
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
|
||||
app.useGlobalGuards(new HostGuard());
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
forbidUnknownValues: true,
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
await app.register(fastifyCookie);
|
||||
await app.register(fastifyHelmet.default);
|
||||
await app.register(fastifyMultipart.default, {
|
||||
limits: {
|
||||
fieldNameSize: 100,
|
||||
fieldSize: 100,
|
||||
fields: 0,
|
||||
files: 1,
|
||||
headerPairs: 20,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
await app.register(fastifyCookie);
|
||||
await app.register(fastifyHelmet.default);
|
||||
await app.register(fastifyMultipart.default, {
|
||||
limits: {
|
||||
fieldNameSize: 100,
|
||||
fieldSize: 100,
|
||||
fields: 0,
|
||||
files: 1,
|
||||
headerPairs: 20,
|
||||
},
|
||||
});
|
||||
await app.listen(8080, '0.0.0.0', (error, address) => {
|
||||
if (error) throw error;
|
||||
logger.log(`Listening at ${address}`);
|
||||
});
|
||||
}
|
||||
|
||||
await app.listen(8080, '0.0.0.0', (error, address) => {
|
||||
if (error) throw error;
|
||||
logger.log(`Listening at ${address}`);
|
||||
// top-level await is not supported by ncc
|
||||
bootstrap().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
@ -199,7 +199,6 @@ export class FileService implements OnApplicationBootstrap {
|
|||
onApplicationBootstrap() {
|
||||
if (config.purge) {
|
||||
const size = bytes.format(config.purge.overLimit);
|
||||
// todo: swap out luxon for dayjs
|
||||
const age = DateTime.local().minus(config.purge.afterTime).toRelative();
|
||||
this.logger.warn(`Purging files is enabled for files over ${size} uploaded more than ${age}.`);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"include": ["src"],
|
||||
"include": ["src", "types"],
|
||||
"compilerOptions": {
|
||||
// https://www.npmjs.com/package/@tsconfig/node16
|
||||
// https://github.com/sindresorhus/tsconfig/blob/main/tsconfig.json
|
||||
|
@ -32,7 +32,8 @@
|
|||
"baseUrl": ".",
|
||||
"paths": {
|
||||
// https://github.com/bevry/istextorbinary/issues/270
|
||||
"istextorbinary": ["node_modules/istextorbinary/compiled-types/index.d.ts"]
|
||||
// voids the bad types or else ncc fails
|
||||
"istextorbinary": ["*.sink.d.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,6 @@ module.exports = {
|
|||
'jsx-a11y/media-has-caption': 'off',
|
||||
'@typescript-eslint/no-confusing-void-expression': 'off',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
||||
'@typescript-eslint/no-misused-promises': 'off',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@ import { Ping } from './ping';
|
|||
export interface StepsProps {
|
||||
steps: string[];
|
||||
stepIndex: number;
|
||||
onClick?: (index: number) => void;
|
||||
}
|
||||
|
||||
export const Steps: FC<StepsProps> = ({ steps, stepIndex }) => {
|
||||
|
|
|
@ -5,47 +5,49 @@ import { ChevronDown } from 'react-feather';
|
|||
import languages from '../../data/languages.json';
|
||||
import { useToasts } from '@ryanke/pandora';
|
||||
|
||||
export interface SyntaxHighlighterControls {
|
||||
export interface SyntaxHighlighterControlsProps {
|
||||
onLanguageChange: (language: Language) => void;
|
||||
language: Language;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export const SyntaxHighlighterControls = memo<SyntaxHighlighterControls>(({ language, content, onLanguageChange }) => {
|
||||
const createToast = useToasts();
|
||||
const copyContent = () => {
|
||||
navigator.clipboard.writeText(content);
|
||||
createToast({ text: 'Copied file content to clipboard.' });
|
||||
};
|
||||
export const SyntaxHighlighterControls = memo<SyntaxHighlighterControlsProps>(
|
||||
({ language, content, onLanguageChange }) => {
|
||||
const createToast = useToasts();
|
||||
const copyContent = () => {
|
||||
navigator.clipboard.writeText(content);
|
||||
createToast({ text: 'Copied file content to clipboard.' });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="absolute right-0 top-0 flex items-center gap-2 z-10 bg-black bg-opacity-75 hover:bg-opacity-100 rounded-bl-lg pl-2 pb-2">
|
||||
<Menu as="div" className="relative">
|
||||
<Menu.Button className="text-xs flex items-center gap-1 text-gray-500 hover:text-white transition pt-2 ">
|
||||
{language} <ChevronDown className="h-4 w-4" />
|
||||
</Menu.Button>
|
||||
<Menu.Items className="absolute top-full mt-3 bg-gray-900 text-sm max-h-44 overflow-y-scroll text-xs right-0 rounded">
|
||||
{languages.map((language) => (
|
||||
<Menu.Item
|
||||
as="div"
|
||||
key={language.name}
|
||||
className="text-gray-400 hover:text-white transition cursor-pointer truncate px-3 py-1 hover:bg-gray-800"
|
||||
onClick={() => {
|
||||
onLanguageChange(language.key as Language);
|
||||
}}
|
||||
>
|
||||
{language.name}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Menu>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-gray-500 hover:text-white transition pr-3 pt-2"
|
||||
onClick={copyContent}
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className="absolute right-0 top-0 flex items-center gap-2 z-10 bg-black bg-opacity-75 hover:bg-opacity-100 rounded-bl-lg pl-2 pb-2">
|
||||
<Menu as="div" className="relative">
|
||||
<Menu.Button className="text-xs flex items-center gap-1 text-gray-500 hover:text-white transition pt-2 ">
|
||||
{language} <ChevronDown className="h-4 w-4" />
|
||||
</Menu.Button>
|
||||
<Menu.Items className="absolute top-full mt-3 bg-gray-900 text-sm max-h-44 overflow-y-scroll text-xs right-0 rounded">
|
||||
{languages.map((language) => (
|
||||
<Menu.Item
|
||||
as="div"
|
||||
key={language.name}
|
||||
className="text-gray-400 hover:text-white transition cursor-pointer truncate px-3 py-1 hover:bg-gray-800"
|
||||
onClick={() => {
|
||||
onLanguageChange(language.key as Language);
|
||||
}}
|
||||
>
|
||||
{language.name}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Menu>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-gray-500 hover:text-white transition pr-3 pt-2"
|
||||
onClick={copyContent}
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function Generate() {
|
|||
const [result, setResult] = useState<GenerateOtpMutation | null>(null);
|
||||
const createToast = useToasts();
|
||||
const router = useRouter();
|
||||
const [currentStep, setCurrentStep] = useQueryState('step', 0, (value) => Number(value));
|
||||
const [currentStep, setCurrentStep] = useQueryState('step', 0, Number);
|
||||
const [confirmOtp] = useConfirmOtpMutation();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Reference in New Issue