@@ -5,3 +5,74 @@ Get familiar with your browser by solving CTF only with your devtools
55** Supports all common browsers
66
77** Fuck IE don't even try!
8+
9+ # Development
10+
11+ Here is a quick guide to develop more levels
12+
13+ ## Creating A new Level
14+
15+ ### Create a new Page
16+
17+ Create a new ` .hbs ` file in ` pages ` (e.g. ` my-level.hbs ` )
18+ ** \* use ` ! ` + ` Tab ` to generate basic HTML structure, or copy-paste another ` .hbs ` file**
19+
20+ example for body content in a level:
21+
22+ ``` handlebars
23+ <div>
24+ the flag is {{flag}}
25+ </div>
26+ ```
27+
28+ ` {{flag}} ` serves as a placeholder for data injection from the server
29+
30+ ### Create Level Configuration
31+
32+ add to ` config.ts ` the following:
33+
34+ ``` typescript
35+ export default {
36+ levels: {
37+ /* {... Other levels}*/
38+ myLevel: createLevelConfig (' MY_LEVEL' , {
39+ url: ' level-123456' ,
40+ flag: createFlag (' myFl4G' )
41+ })
42+ }
43+ }
44+ ```
45+
46+ NOTE: don't copy-paste like an idiot, you might delete other levels by accident.
47+
48+ ### Create a new Controller
49+
50+ ``` bash
51+ $ nest g co myLevel controllers --flat
52+ ```
53+
54+ This command will create a new ` my-level.controller.ts ` file inside ` controllers/ ` directory. ` --flat ` means it will not
55+ create a ` my-level/ ` directory too.
56+
57+ To create a route that displays content, add ` @Get() ` to specify your request method, and ` @Render ` to specify which page you want to render
58+
59+ ``` typescript
60+ import config from ' ~/config' ;
61+
62+ const levelConfig = config .levels .myLevel
63+
64+ @Controller (levelConfig .url )
65+ export class MyLevelController {
66+ @Get ()
67+ @Render (' my-level.hbs' )
68+ render() {
69+ // this defines the variables for my-level.hbs
70+ return {
71+ flag: levelConfig .flag ,
72+ };
73+ }
74+ }
75+ ```
76+
77+ to add more routes just learn ` nestjs ` , and put them inside the relevant controller.
78+
0 commit comments