@compas/code-gen
TypeScript icon, indicating that this package has built-in type declarations

0.15.6 • Public • Published

@compas/code-gen

Install size CI status badge Codecov status


Code generators for routers, validators, SQL queries, API clients and more. Take a look at the documentation.

As a server

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"],
  });
}

As a client

mainFn(import.meta, main);

async function main() {
  const app = new App({ verbose: true });

  const 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"]);
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.15.659latest

Version History

VersionDownloads (Last 7 Days)Published
0.15.659
0.15.5114
0.15.427
0.15.381
0.15.248
0.15.10
0.15.00
0.14.1115
0.14.06
0.13.10
0.13.00
0.12.40
0.12.32
0.12.20
0.12.10
0.12.06
0.11.224
0.11.10
0.11.00
0.10.67
0.10.51
0.10.40
0.10.31
0.10.20
0.10.10
0.10.0227
0.9.07
0.8.112
0.8.00
0.7.63
0.7.50
0.7.4224
0.7.30
0.7.20
0.7.10
0.7.02
0.6.00
0.5.512
0.5.40
0.5.30
0.5.20
0.5.10
0.5.02
0.4.02
0.3.20
0.3.10
0.3.00
0.2.00
0.1.00
0.0.2496
0.0.2480
0.0.2470
0.0.2460
0.0.2450
0.0.2442
0.0.24316
0.0.2420
0.0.2410
0.0.2400
0.0.2391
0.0.2380
0.0.2370
0.0.2360
0.0.2350
0.0.2340
0.0.2330
0.0.2320
0.0.2310
0.0.2300
0.0.2290
0.0.2280
0.0.2270
0.0.2261
0.0.2250
0.0.2240
0.0.2230
0.0.2222
0.0.2212
0.0.2201
0.0.2191
0.0.2184
0.0.2170
0.0.2160
0.0.2151
0.0.2140
0.0.2130
0.0.2122
0.0.21162
0.0.2100
0.0.2091
0.0.2080
0.0.2070
0.0.2060
0.0.2050
0.0.2042
0.0.2030
0.0.2020
0.0.2010
0.0.2000
0.0.1990
0.0.1986
0.0.1971
0.0.1960
0.0.1950
0.0.1940
0.0.1932
0.0.1920
0.0.1910
0.0.1900
0.0.1892
0.0.1880
0.0.1870
0.0.1861
0.0.1850
0.0.1840
0.0.1830
0.0.1821
0.0.1810
0.0.1800
0.0.1790
0.0.1780
0.0.1770
0.0.1760
0.0.1751
0.0.1740
0.0.1730
0.0.1720
0.0.1710
0.0.1700
0.0.1690
0.0.1680
0.0.1670
0.0.1660
0.0.1650
0.0.1641
0.0.1630
0.0.1621
0.0.1613
0.0.1601
0.0.1594
0.0.1580
0.0.1570
0.0.1560
0.0.1550
0.0.1530
0.0.1522
0.0.1513
0.0.1500
0.0.1491
0.0.1480
0.0.1470
0.0.1460
0.0.1450
0.0.1440
0.0.1430
0.0.1420
0.0.1410
0.0.1401
0.0.1390
0.0.1380
0.0.1371
0.0.1360
0.0.1350
0.0.1340
0.0.1330
0.0.1322
0.0.1310
0.0.1300
0.0.1291
0.0.1280
0.0.1270
0.0.1265
0.0.1251
0.0.1240
0.0.1230
0.0.1221
0.0.1210
0.0.1200
0.0.1190
0.0.1181
0.0.1170
0.0.1160
0.0.1150
0.0.1140
0.0.1130
0.0.1121
0.0.1110
0.0.1100
0.0.1090
0.0.1080
0.0.1070
0.0.1061
0.0.1050
0.0.1040
0.0.1030

Package Sidebar

Install

npm i @compas/code-gen

Homepage

compasjs.com

Weekly Downloads

1,131

Version

0.15.6

License

MIT

Unpacked Size

1.45 MB

Total Files

202

Last publish

Collaborators

  • dirkdev98