A Bun template that supports building TypeScript hooks for your PocketBase application.
This template is designated for developing with Dev Containers. You only need to add its associated extension to your Visual Studio Code along with ensuring that Docker is available in your machine.
If you just want to go on your way, please make sure that the following dependencies are available:
For adding a new dependency, we can use bun install
command. For example, if we want to use the functionalities of the npm package is-even, run the following command:
bun install is-even
For installing all dependencies defined in package.json
, run:
bun install
To add a new TypeScript hook, create a .pb.ts
file (it is mandatory that a PocketBase hook must end with .pb.js
) inside the src
directory. For type hints, we can add a reference triple-slash directive at the beginning of the file:
/// <reference path="../types/pocketbase.d.ts" />
For reference, please take a look at this overview of Extending with JavaScript.
Building is a step to compile our TypeScript files into JavaScript and move the built ones to the right place for our PocketBase application. To do that, run:
bun run build
If the building process succeeds, a directory pb_data
will be created in the current workspace.
After building, we can start our PocketBase application via:
pocketbase serve --dir=pb_data --hooksDir=pb_data/pb_hooks
The application will listen on port 8090
and, of course, be integrated with our added JavaScript hooks.
For more convenience in local development, we can use
bun dev
to start the application right after building.
For more other helpful scripts for development, take a look at bun run help
command.
This template is made for personal uses. Please use it at your own risk and feel free to create a pull request if you have and suggestion to make it better.