
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@compas/code-gen
Advanced tools
Code generators for routers, validators, SQL queries, API clients and more. Take a look at the documentation.
mainFn(import.meta, main);
async function main() {
const app = new App();
const T = new TypeCreator("post");
const R = T.router("/post");
app.add(
new TypeCreator("database")
.object("post")
.keys({
title: T.string().searchable(),
body: T.string(),
})
.enableQueries({ withDates: true }),
T.crud("/post").entity(T.reference("database", "post")).routes({
listRoute: true,
singleRoute: true,
createRoute: true,
updateRoute: true,
deleteRoute: true,
}),
);
await app.generate({
outputDirectory: "./src/generated/application",
dumpStructure: true,
dumpApiStructure: true,
dumpPostgres: true,
enabledGenerators: ["validator", "router", "sql", "apiClient"],
});
}
mainFn(import.meta, main);
async function main() {
const app = new App({ verbose: true });
let fromRemote = await loadApiStructureFromRemote(
Axios,
"https://some.compas.powered.backend",
);
app.extend(fromRemote);
await app.generate({
outputDirectory: "./src/generated",
isBrowser: true,
enabledGenerators: ["type", "apiClient", "reactQuery"],
});
await spawn("yarn", ["format"]);
}
There are a few structure breaking changes to clean up compatibility with old code-gen. Make sure that the API is updated before any consumer is.
bacfe3
newMigrateContext
to migrationsInitContext
. It also accepts an
object with migrationsDirectory
instead of a 'string' as the second
argument. As before, if you don't provide a migrationsDirectory
it
defaults to $cwd/migrations
.getMigrationsToBeApplied
to migrationsGetInfo
. The result is
wrapped in a promise.runMigrations
to migrationsRun
.--keep-alive
and --without-lock
from compas migrate
. If you
need this functionality, you are better off calling the migration functions
on application startup.T.any().raw()
and T.any().validator()
9d4f7a
T.any().raw()
and T.any().validator()
were not implemented in the new
code-gen. Use T.any().implementations()
instead.T.bool().convert()
, T.number().convert()
and
T.string().convert()
d704a6
T.array().convert()
d3aabb
R.files()
569b2b
R.body()
instead of R.files()
ctx.validatedFiles
with
ctx.validatedBody
PostSetHeaderImageFiles
will be renamed to PostSetHeaderImageBody
.T.uuid()
,
T.date().{timeOnly,dateOnly}()
41e3e3
R.params()
and R.query()
21c9b7
useQuery
hooks
430449
T.file()
in R.body()
(#2597)
80429b
077da8
T.array().convert()
to the docs
9744e6
4b7ba7
FAQs
Generate various boring parts of your server
The npm package @compas/code-gen receives a total of 434 weekly downloads. As such, @compas/code-gen popularity was classified as not popular.
We found that @compas/code-gen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.