| 1 |
{ |
| 2 |
"apiVersion": 3, |
| 3 |
"$schema": "https://schemas.wp.org/trunk/block.json", |
| 4 |
"name": "blockenberg/course-lesson", |
| 5 |
"title": "Course Lesson", |
| 6 |
"description": "A complete course lesson with objectives, content sections, resources, and navigation.", |
| 7 |
"category": "bkbg-blog", |
| 8 |
"icon": "welcome-learn-more", |
| 9 |
"keywords": [ |
| 10 |
"course", |
| 11 |
"lesson", |
| 12 |
"module", |
| 13 |
"learning", |
| 14 |
"tutorial", |
| 15 |
"class", |
| 16 |
"education", |
| 17 |
"lms" |
| 18 |
], |
| 19 |
"textdomain": "blockenberg", |
| 20 |
"editorScript": "bkbg-course-lesson-editor", |
| 21 |
"editorStyle": "bkbg-course-lesson-style", |
| 22 |
"style": "bkbg-course-lesson-style", |
| 23 |
"viewScript": "bkbg-course-lesson-frontend", |
| 24 |
"supports": { |
| 25 |
"html": false, |
| 26 |
"anchor": true, |
| 27 |
"className": true, |
| 28 |
"align": [ |
| 29 |
"wide", |
| 30 |
"full" |
| 31 |
] |
| 32 |
}, |
| 33 |
"attributes": { |
| 34 |
"lessonTitle": { |
| 35 |
"type": "string", |
| 36 |
"default": "Building REST APIs with Node.js" |
| 37 |
}, |
| 38 |
"moduleTitle": { |
| 39 |
"type": "string", |
| 40 |
"default": "Module 4: APIs & Data" |
| 41 |
}, |
| 42 |
"showModule": { |
| 43 |
"type": "boolean", |
| 44 |
"default": true |
| 45 |
}, |
| 46 |
"lessonNumber": { |
| 47 |
"type": "string", |
| 48 |
"default": "Lesson 3 of 8" |
| 49 |
}, |
| 50 |
"showLessonNumber": { |
| 51 |
"type": "boolean", |
| 52 |
"default": true |
| 53 |
}, |
| 54 |
"duration": { |
| 55 |
"type": "string", |
| 56 |
"default": "45 min" |
| 57 |
}, |
| 58 |
"showDuration": { |
| 59 |
"type": "boolean", |
| 60 |
"default": true |
| 61 |
}, |
| 62 |
"difficulty": { |
| 63 |
"type": "string", |
| 64 |
"default": "intermediate" |
| 65 |
}, |
| 66 |
"showDifficulty": { |
| 67 |
"type": "boolean", |
| 68 |
"default": true |
| 69 |
}, |
| 70 |
"instructor": { |
| 71 |
"type": "string", |
| 72 |
"default": "Alex Martinez" |
| 73 |
}, |
| 74 |
"showInstructor": { |
| 75 |
"type": "boolean", |
| 76 |
"default": true |
| 77 |
}, |
| 78 |
"prerequisites": { |
| 79 |
"type": "array", |
| 80 |
"default": [ |
| 81 |
"Basic understanding of JavaScript and Node.js", |
| 82 |
"Familiarity with HTTP methods (GET, POST, PUT, DELETE)", |
| 83 |
"Node.js installed on your machine" |
| 84 |
] |
| 85 |
}, |
| 86 |
"showPrerequisites": { |
| 87 |
"type": "boolean", |
| 88 |
"default": true |
| 89 |
}, |
| 90 |
"prerequisitesLabel": { |
| 91 |
"type": "string", |
| 92 |
"default": "Prerequisites" |
| 93 |
}, |
| 94 |
"objectives": { |
| 95 |
"type": "array", |
| 96 |
"default": [ |
| 97 |
"Set up an Express.js server from scratch", |
| 98 |
"Create CRUD endpoints with proper status codes", |
| 99 |
"Validate request data using middleware", |
| 100 |
"Connect to a database and handle async operations" |
| 101 |
] |
| 102 |
}, |
| 103 |
"showObjectives": { |
| 104 |
"type": "boolean", |
| 105 |
"default": true |
| 106 |
}, |
| 107 |
"objectivesLabel": { |
| 108 |
"type": "string", |
| 109 |
"default": "What You'll Learn" |
| 110 |
}, |
| 111 |
"intro": { |
| 112 |
"type": "string", |
| 113 |
"default": "In this lesson, you'll build a fully functional REST API using Express.js. We'll cover everything from project setup and route definition to data validation and database integration — all with real-world patterns you can use immediately." |
| 114 |
}, |
| 115 |
"showIntro": { |
| 116 |
"type": "boolean", |
| 117 |
"default": true |
| 118 |
}, |
| 119 |
"sections": { |
| 120 |
"type": "array", |
| 121 |
"default": [ |
| 122 |
{ |
| 123 |
"heading": "Setting Up the Project", |
| 124 |
"content": "Start by initializing a new Node.js project and installing Express. Run `npm init -y && npm install express` in your terminal. Create a file called `server.js` and require Express at the top.", |
| 125 |
"type": "text" |
| 126 |
}, |
| 127 |
{ |
| 128 |
"heading": "Defining Your First Route", |
| 129 |
"content": "Use `app.get()` to define a GET route. The callback receives a `req` (request) and `res` (response) object. Call `res.json()` to send JSON data back to the client.", |
| 130 |
"type": "text" |
| 131 |
}, |
| 132 |
{ |
| 133 |
"heading": "Pro Tip: Use nodemon During Development", |
| 134 |
"content": "Install nodemon as a dev dependency (`npm install -D nodemon`) and add a `dev` script to your package.json: `\"dev\": \"nodemon server.js\"`. This automatically restarts your server on file changes.", |
| 135 |
"type": "tip" |
| 136 |
}, |
| 137 |
{ |
| 138 |
"heading": "Handling POST Requests & Body Parsing", |
| 139 |
"content": "For POST and PUT routes, you need to parse the request body. Add `app.use(express.json())` before your routes. Access the parsed body via `req.body`.", |
| 140 |
"type": "text" |
| 141 |
}, |
| 142 |
{ |
| 143 |
"heading": "Important: Always Validate User Input", |
| 144 |
"content": "Never trust data coming from the client. Validate required fields before processing and return a 400 status code with a clear error message if validation fails.", |
| 145 |
"type": "warning" |
| 146 |
} |
| 147 |
] |
| 148 |
}, |
| 149 |
"showSections": { |
| 150 |
"type": "boolean", |
| 151 |
"default": true |
| 152 |
}, |
| 153 |
"resources": { |
| 154 |
"type": "array", |
| 155 |
"default": [ |
| 156 |
{ |
| 157 |
"title": "Express.js Official Docs", |
| 158 |
"url": "https://expressjs.com", |
| 159 |
"type": "article" |
| 160 |
}, |
| 161 |
{ |
| 162 |
"title": "Starter Code on GitHub", |
| 163 |
"url": "https://github.com/example", |
| 164 |
"type": "download" |
| 165 |
}, |
| 166 |
{ |
| 167 |
"title": "Video Walkthrough (22 min)", |
| 168 |
"url": "https://youtube.com/example", |
| 169 |
"type": "video" |
| 170 |
}, |
| 171 |
{ |
| 172 |
"title": "Practice Exercise: Build a Todo API", |
| 173 |
"url": "#exercise", |
| 174 |
"type": "exercise" |
| 175 |
} |
| 176 |
] |
| 177 |
}, |
| 178 |
"showResources": { |
| 179 |
"type": "boolean", |
| 180 |
"default": true |
| 181 |
}, |
| 182 |
"resourcesLabel": { |
| 183 |
"type": "string", |
| 184 |
"default": "Resources" |
| 185 |
}, |
| 186 |
"prevLesson": { |
| 187 |
"type": "string", |
| 188 |
"default": "HTTP Fundamentals & Status Codes" |
| 189 |
}, |
| 190 |
"prevLessonUrl": { |
| 191 |
"type": "string", |
| 192 |
"default": "#" |
| 193 |
}, |
| 194 |
"nextLesson": { |
| 195 |
"type": "string", |
| 196 |
"default": "Authentication with JWT" |
| 197 |
}, |
| 198 |
"nextLessonUrl": { |
| 199 |
"type": "string", |
| 200 |
"default": "#" |
| 201 |
}, |
| 202 |
"showNav": { |
| 203 |
"type": "boolean", |
| 204 |
"default": true |
| 205 |
}, |
| 206 |
"fontSize": { |
| 207 |
"type": "number", |
| 208 |
"default": 15 |
| 209 |
}, |
| 210 |
"titleFontSize": { |
| 211 |
"type": "number", |
| 212 |
"default": 26 |
| 213 |
}, |
| 214 |
"lineHeight": { |
| 215 |
"type": "number", |
| 216 |
"default": 170 |
| 217 |
}, |
| 218 |
"borderRadius": { |
| 219 |
"type": "number", |
| 220 |
"default": 12 |
| 221 |
}, |
| 222 |
"moduleTitleSize": { |
| 223 |
"type": "number", |
| 224 |
"default": 11 |
| 225 |
}, |
| 226 |
"bgColor": { |
| 227 |
"type": "string", |
| 228 |
"default": "#ffffff" |
| 229 |
}, |
| 230 |
"borderColor": { |
| 231 |
"type": "string", |
| 232 |
"default": "#e5e7eb" |
| 233 |
}, |
| 234 |
"headerBg": { |
| 235 |
"type": "string", |
| 236 |
"default": "#0f172a" |
| 237 |
}, |
| 238 |
"headerColor": { |
| 239 |
"type": "string", |
| 240 |
"default": "#ffffff" |
| 241 |
}, |
| 242 |
"metaColor": { |
| 243 |
"type": "string", |
| 244 |
"default": "#94a3b8" |
| 245 |
}, |
| 246 |
"introBg": { |
| 247 |
"type": "string", |
| 248 |
"default": "#f0f9ff" |
| 249 |
}, |
| 250 |
"introColor": { |
| 251 |
"type": "string", |
| 252 |
"default": "#0369a1" |
| 253 |
}, |
| 254 |
"objectiveBg": { |
| 255 |
"type": "string", |
| 256 |
"default": "#f0fdf4" |
| 257 |
}, |
| 258 |
"objectiveColor": { |
| 259 |
"type": "string", |
| 260 |
"default": "#14532d" |
| 261 |
}, |
| 262 |
"objectiveDot": { |
| 263 |
"type": "string", |
| 264 |
"default": "#22c55e" |
| 265 |
}, |
| 266 |
"prereqBg": { |
| 267 |
"type": "string", |
| 268 |
"default": "#f8fafc" |
| 269 |
}, |
| 270 |
"prereqColor": { |
| 271 |
"type": "string", |
| 272 |
"default": "#374151" |
| 273 |
}, |
| 274 |
"prereqDot": { |
| 275 |
"type": "string", |
| 276 |
"default": "#94a3b8" |
| 277 |
}, |
| 278 |
"textColor": { |
| 279 |
"type": "string", |
| 280 |
"default": "#374151" |
| 281 |
}, |
| 282 |
"headingColor": { |
| 283 |
"type": "string", |
| 284 |
"default": "#111827" |
| 285 |
}, |
| 286 |
"tipBg": { |
| 287 |
"type": "string", |
| 288 |
"default": "#fefce8" |
| 289 |
}, |
| 290 |
"tipColor": { |
| 291 |
"type": "string", |
| 292 |
"default": "#713f12" |
| 293 |
}, |
| 294 |
"tipBorder": { |
| 295 |
"type": "string", |
| 296 |
"default": "#fbbf24" |
| 297 |
}, |
| 298 |
"warningBg": { |
| 299 |
"type": "string", |
| 300 |
"default": "#fff7ed" |
| 301 |
}, |
| 302 |
"warningColor": { |
| 303 |
"type": "string", |
| 304 |
"default": "#9a3412" |
| 305 |
}, |
| 306 |
"warningBorder": { |
| 307 |
"type": "string", |
| 308 |
"default": "#f97316" |
| 309 |
}, |
| 310 |
"noteBg": { |
| 311 |
"type": "string", |
| 312 |
"default": "#eff6ff" |
| 313 |
}, |
| 314 |
"noteColor": { |
| 315 |
"type": "string", |
| 316 |
"default": "#1e40af" |
| 317 |
}, |
| 318 |
"noteBorder": { |
| 319 |
"type": "string", |
| 320 |
"default": "#3b82f6" |
| 321 |
}, |
| 322 |
"resourceBg": { |
| 323 |
"type": "string", |
| 324 |
"default": "#f8fafc" |
| 325 |
}, |
| 326 |
"accentColor": { |
| 327 |
"type": "string", |
| 328 |
"default": "#3b82f6" |
| 329 |
}, |
| 330 |
"navBg": { |
| 331 |
"type": "string", |
| 332 |
"default": "#f8fafc" |
| 333 |
}, |
| 334 |
"typoTitle": { |
| 335 |
"type": "object", |
| 336 |
"default": {} |
| 337 |
}, |
| 338 |
"typoBody": { |
| 339 |
"type": "object", |
| 340 |
"default": {} |
| 341 |
} |
| 342 |
} |
| 343 |
} |
| 344 |
|