Skip to content

v0.6.0-beta.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@LoicPoullain LoicPoullain released this 22 Aug 08:18
· 4370 commits to master since this release

Features

  • Do not have to manually register each entity (issue #174).
  • Improve installation speed (from 28/31/34 s to 12/14/14 s) (issue #174).
  • Reduce the number of dependencies (mainly for security reasons) (total dependencies for @foal/cli: 901 -> 34) (issue #174).
  • Set the stage to have a REPL shell (issue #137).
  • Set the stage to create users, groups and permissions easily through a command line (issue #162).
  • Be able to use the database in the constructor of a service or more widely before a request is received.
  • Fix this issue: if the first requests are made simultaneously then some of them may not have the connection established to the database.
  • Improve the test experience: the client should be able to run its tests without registering them into a test.ts file (issue #174).
  • Set the stage to improve "smooth" debugging in vscode (issue #174).
  • Improve "hard" (by hand) debugging (issue #174).
  • Support multiple database connections
  • [Internal] Remove build complexity (issue #174).

Steps

  • Remove InitDB and add a createConnection in the main index.ts file instead.
  • Update the build, run and test commands to use copy and to get rid of webpack.
  • Update tsconfig.json and ormconfig.json to use the correct paths.
  • Move the scripts/ directory into src.
  • Replace all the require('**/*.html') by fs reads.

How to migrate

  • Delete your lib/ directory.
  • Update your dependencies by running npm update.
  • The hook InitDB does not longer exist and you don't need to register your entities anymore. Remove the hook from your code and replace the content of src/index.ts by this:
// The imports ...
async function main() {
  await createConnection();

  const app = createApp(AppModule, {
    store: session => new (sqliteStoreFactory(session))({ db: 'db.sqlite3' })
  });

  const httpServer = http.createServer(app);
  const port = Config.get('settings', 'port', 3000);
  httpServer.listen(port, () => {
    console.log(`Listening on port ${port}...`);
  });
}

main();
  • Change the commands of your package.json by this:
{
    "build": "tsc && copy-cli \"src/**/*.html\" lib",
    "build:w": "tsc -w",
    "start": "node ./lib/index.js",
    "start:w": "supervisor -w ./lib --no-restart-on error ./lib/index.js",
    "develop": "npm run build && concurrently \"npm run build:w\" \"npm run start:w\"",

    "build:test": "tsc && copy-cli \"src/**/*.html\" lib",
    "build:test:w": "tsc -w",
    "start:test": "mocha \"./lib/**/*.spec.js\"",
    "start:test:w": "mocha -w \"./lib/**/*.spec.js\"",
    "test": "npm run build:test && concurrently \"npm run build:test:w\" \"npm run start:test:w\"",

    "lint": "tslint -c tslint.json -p tsconfig.json",
    "migration:generate": "ts-node ./node_modules/.bin/typeorm migration:generate",
    "migration:run": "ts-node ./node_modules/.bin/typeorm migration:run",
    "migration:revert": "ts-node ./node_modules/.bin/typeorm migration:revert"
}
  • Update the following properties in your tsconfig.json and ormconfig.json:
// tsconfig
"outDir": "lib" 
//ormconfig
 "entities": ["lib/app/**/*.entity.js"],
  • Move your scripts/ directory to src.
  • Replace all your require('./foobar.html') to fs.readFileSync(path.join(__dirname, './foobar.html'), 'utf8').