tomfa / booking-service Goto Github PK
View Code? Open in Web Editor NEWA draft of a booking saas
A draft of a booking saas
api.vailable.eu
Given a token, what's my customerId? userId? issuer?
Booking multiple rooms at once should be a possibility.
Creating a schedule is quite cumbersome.
Make it easier? Yes.
Disabled resources should not be returned unless explicitly asked for.
I bet there is no problem adding negative length slots or resources with opening hours that are strings outside the intended format.
Case:
Thoughts:
Solution?:
Fix shared package. Then add new package vailable-auth with help methods for creating tokens, with autocomplete for permissions.
import auth from 'vailable-auth';
const userToken = auth.createToken({
secretKey: string,
accountId: string,
userId: string,
permissions: Permission[] = ['vailable:role:user'],
});
const adminToken = auth.createAdminToken({ secretKey: string, accountId: string });
Migrations are manually in production. Make them automatically run on deploy?
How coujld that be the default?
The code is a copy-paste from github.com/tomfa/pdf-generator-api/.
Rename everything to booking-service
Use same pattern as e.g. Sentry.
import Vailable from 'vailable';
// Instead of
const api = new Vailable({ ... });
api.findResources();
// Do
Vailable.login({ username, password}); // Only require to be run somewhere in the application first
// Alternatively
Valiable.authenticate({ token });
Vailable.isAuthenticated() // true/false
Vailable.findResources();
We can do this by storing auth outside the class instance as a default fallback if class itself does not have auth + making all methods static (can static methods use this?) โ By keeping the class we can then also allow user to make multiple instances of a client for different users (low pri, I'm unsure of the usecase, but there probably is one)
Required fields in JWT
sub
: userIdiss
: url specific to account. E.g. https://api.externaluserhomepage.com
exp
: Unix timestamp / 1000. E.g. 1577836800
for 2020-01-01T00:00:00Z
www.vailable.eu
: JSON object containing account and permissions.{
"sub": "1312",
"iss": "https://YOUR_DOMAIN",
"exp": 1577836800,
"www.vailable.eu": {
"account": "vailable-account-userid",
"permissions": [
"admin/*", // allows everything
"user/*", // allows booking management on behalf of -all- users
"user/1312/*. // allows booking management on behalf of user "1312",
]
}
}
The issuer must expose well known jwks at https://YOUR_DOMAIN/.well-known/jwks.json
, see https://docs.cidaas.com/standard-endpoints/server-jwk-set.html#31-well-knownjwksjson
Resource should be able to have category field added. E.g. DESK
. Free text.
Schedule is returned from with 00:00
-> 00:00
as closed. This doesn't quite work.
We should add an isClosed
or set start/end time to empty string when things are closed?
FindAvailability should return a list of available seatIds.
Need a quick and dirty sdk for development to start on related projects that will use this service.
Can store in-memory, and not handle authentication. This is just for testing/developing.
sdk
is updatedWhen creating a booking, you must specify start and end.
Instead, allow specifying start and lengthMinutes.
Get this deployed at a domain. web + api.
Github actions should autodeploy when changes are made to master. No need for a staging environment (yet anyway)
JWT should be allowed to be used without an active issuer endpoint, by setting public key in Customer database.
For a user with admin priviliges (e.g. on an API), we should be able to call sdk.createUserToken(userID: string, audience?: string, customPriviliges?: string[])
to generate a user token.
Fucking tslib.
__spreadArray is not a function
.
Why? Wrong tslib version. Why was there a wrong tslib version? Because I haven't added tslib to my sdk dependencies? Probably?
Using babel to compile typescript is also an alternative: https://ricostacruz.com/til/babel-typescript
No sub-entities are exposed. Maybe they should?
Say for a party, you could have access to the party or not. No slot duration, interval and only 1 date.
Case: Room A is open (CEST) from 08-16 on Thursday, and 00-00 (all day) Friday.
Adjusted for timezones, this is 06-14
+ 22-00
Thursday + 00-22
Friday CEST.
This is not supported by the way we store Schedule in database, where one day cannot have multiple opening hours, nor in the SDK (getResource
) where the same is the case.
Short term solution (CEST)
addResource
with UTC times.Resource.schedule
.02
)Medium term solution:
Schedule
, generate an array of start + end. The case above would for Thursday store [{start: 06, end: 14 }, { start: 22, end: 00 }]
timezoneoffset
as argument to sdk, which will map any incoming and outgoing references to the clock. It can use new Date().getTimezoneOffset()
as default.Additional DST timezones fix:
For summertime vs wintertime, we want the schedule itself to "jump", 1 hour back and forth wrt. UTC, not just in display.
We can implement a getResourceOffset
function in the api, that adds or subtracts to the schedule before exposing it through GraphQL. This would require a timezone field to be added to the Resource
.
To know for sure what the time represents, we can store a timezone along with the resource (this way, 1 customer can have resources in different timezones).
(Later stage: specify meta info per seat? Now there will be a problem if one reduces the number of seats?)
usecase: admin should be able to reserve x seats for x amount of time for a special project
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.