aionix 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/db/habits.db ADDED
@@ -0,0 +1 @@
1
+ {"name":"hi","frequency":"Weekly","streak":1,"completedDates":["Sun Mar 08 2026"],"createdAt":{"$$date":1772951757182},"_id":"gwWZtgp9zG4REihS"}
package/db/quiz.db ADDED
@@ -0,0 +1,5 @@
1
+ {"topic":"Node.js","question":"What is npm?","options":["Node Package Manager","New Program Mode","None","Network Protocol"],"answer":0,"difficulty":"easy","_id":"1V7ScsLspt23bTmN"}
2
+ {"topic":"CSS","question":"What is flexbox used for?","options":["Animations","Layout","Colors","Fonts"],"answer":1,"difficulty":"easy","_id":"KaZWnnOz8BaWIfyv"}
3
+ {"topic":"JavaScript","question":"What is closure?","options":["A function inside a function","A loop","An array method","None"],"answer":0,"difficulty":"medium","_id":"NR73uDk5JkGohYgT"}
4
+ {"topic":"JavaScript","question":"What does \"=== \" mean?","options":["Assignment","Loose equality","Strict equality","None"],"answer":2,"difficulty":"easy","_id":"rxrzEF1CwXhA916X"}
5
+ {"topic":"React","question":"What is JSX?","options":["A database","JS + HTML syntax","A CSS framework","None"],"answer":1,"difficulty":"easy","_id":"x53jeOcLDASZAioE"}
package/db/snippets.db ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "aionix",
3
+ "version": "1.0.0",
4
+ "description": "Offline Developer Toolkit - Learning, Tools & Productivity",
5
+ "main": "server/app.js",
6
+ "bin": {
7
+ "dev-ai": "./bin/index.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "server/",
12
+ "client/",
13
+ "db/"
14
+ ],
15
+ "keywords": [
16
+ "developer",
17
+ "offline",
18
+ "toolkit",
19
+ "cli",
20
+ "learning",
21
+ "productivity"
22
+ ],
23
+ "author": "Surya Singh",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "chalk": "^4.1.2",
27
+ "express": "^4.18.2",
28
+ "nedb-promises": "^6.2.1",
29
+ "open": "^8.4.2"
30
+ }
31
+ }
package/server/app.js ADDED
@@ -0,0 +1,35 @@
1
+
2
+ const express = require('express');
3
+ const path = require('path');
4
+ const open = require('open');
5
+ const chalk = require('chalk');
6
+
7
+ const snippetsRoute = require('./routes/snippets');
8
+ const quizRoute = require('./routes/quiz');
9
+ const habitsRoute = require('./routes/habits');
10
+ const docsRoute = require('./routes/docs');
11
+
12
+ const app = express();
13
+ const PORT = 3000;
14
+
15
+ app.use(express.json());
16
+ app.use(express.static(path.join(__dirname, '../client')));
17
+
18
+ // Routes
19
+ app.use('/api/snippets', snippetsRoute);
20
+ app.use('/api/quiz', quizRoute);
21
+ app.use('/api/habits', habitsRoute);
22
+ app.use('/api/docs', docsRoute);
23
+
24
+ // Main page
25
+ app.get('/', (req, res) => {
26
+ res.sendFile(path.join(__dirname, '../client/index.html'));
27
+ });
28
+
29
+ app.listen(PORT, async () => {
30
+ console.log(chalk.green(`✅ Server running at http://localhost:${PORT}`));
31
+ console.log(chalk.yellow('Opening browser...'));
32
+ await open(`http://localhost:${PORT}`);
33
+ });
34
+
35
+ module.exports = app;
@@ -0,0 +1,44 @@
1
+
2
+ const express = require('express');
3
+ const router = express.Router();
4
+
5
+ const docs = {
6
+ javascript: [
7
+ { title: 'Variables', content: 'var, let, const - use let/const always. let is block scoped, const cannot be reassigned.' },
8
+ { title: 'Arrow Functions', content: 'const fn = (a, b) => a + b; — shorter syntax, no own "this"' },
9
+ { title: 'Promises', content: 'new Promise((resolve, reject) => {}). Use .then() .catch() or async/await' },
10
+ { title: 'Array Methods', content: 'map(), filter(), reduce(), find(), forEach(), some(), every()' },
11
+ { title: 'Destructuring', content: 'const {a, b} = obj; or const [x, y] = arr;' },
12
+ ],
13
+ react: [
14
+ { title: 'useState', content: 'const [state, setState] = useState(initialValue); — for local component state' },
15
+ { title: 'useEffect', content: 'useEffect(() => { }, [deps]); — runs after render, deps array controls when' },
16
+ { title: 'Props', content: 'Pass data to child components. function Child({name}) { return <p>{name}</p> }' },
17
+ { title: 'JSX Rules', content: 'Return single root element, use className not class, self-close empty tags' },
18
+ ],
19
+ nodejs: [
20
+ { title: 'require vs import', content: 'require() is CommonJS (Node default). import is ES Modules (add "type":"module")' },
21
+ { title: 'fs module', content: 'fs.readFile(), fs.writeFile(), fs.existsSync() — for file operations' },
22
+ { title: 'Express basics', content: 'app.get/post/put/delete(route, handler). req.body, req.params, res.json()' },
23
+ ],
24
+ css: [
25
+ { title: 'Flexbox', content: 'display:flex; justify-content; align-items; flex-direction; flex-wrap;' },
26
+ { title: 'Grid', content: 'display:grid; grid-template-columns; grid-gap; grid-area;' },
27
+ { title: 'Variables', content: ':root { --color: red; } then use var(--color)' },
28
+ ]
29
+ };
30
+
31
+ router.get('/', (req, res) => {
32
+ res.json(Object.keys(docs));
33
+ });
34
+
35
+ router.get('/:lang', (req, res) => {
36
+ const lang = req.params.lang.toLowerCase();
37
+ if (docs[lang]) {
38
+ res.json(docs[lang]);
39
+ } else {
40
+ res.status(404).json({ error: 'Docs not found' });
41
+ }
42
+ });
43
+
44
+ module.exports = router;
@@ -0,0 +1,62 @@
1
+
2
+ const express = require('express');
3
+ const router = express.Router();
4
+ const Datastore = require('nedb-promises');
5
+ const path = require('path');
6
+
7
+ const db = Datastore.create(path.join(__dirname, '../../db/habits.db'));
8
+
9
+ // Get all habits
10
+ router.get('/', async (req, res) => {
11
+ try {
12
+ const habits = await db.find({}).sort({ createdAt: -1 });
13
+ res.json(habits);
14
+ } catch (err) {
15
+ res.status(500).json({ error: err.message });
16
+ }
17
+ });
18
+
19
+ // Add habit
20
+ router.post('/', async (req, res) => {
21
+ try {
22
+ const { name, frequency } = req.body;
23
+ const habit = await db.insert({
24
+ name, frequency,
25
+ streak: 0,
26
+ completedDates: [],
27
+ createdAt: new Date()
28
+ });
29
+ res.json(habit);
30
+ } catch (err) {
31
+ res.status(500).json({ error: err.message });
32
+ }
33
+ });
34
+
35
+ // Mark habit complete today
36
+ router.patch('/:id/complete', async (req, res) => {
37
+ try {
38
+ const today = new Date().toDateString();
39
+ const habit = await db.findOne({ _id: req.params.id });
40
+ if (!habit.completedDates.includes(today)) {
41
+ await db.update(
42
+ { _id: req.params.id },
43
+ { $push: { completedDates: today }, $inc: { streak: 1 } }
44
+ );
45
+ }
46
+ res.json({ success: true });
47
+ } catch (err) {
48
+ res.status(500).json({ error: err.message });
49
+ }
50
+ });
51
+
52
+ // Delete habit
53
+ router.delete('/:id', async (req, res) => {
54
+ try {
55
+ await db.remove({ _id: req.params.id });
56
+ res.json({ success: true });
57
+ } catch (err) {
58
+ res.status(500).json({ error: err.message });
59
+ }
60
+ });
61
+
62
+ module.exports = router;
@@ -0,0 +1,46 @@
1
+
2
+ const express = require('express');
3
+ const router = express.Router();
4
+ const Datastore = require('nedb-promises');
5
+ const path = require('path');
6
+
7
+ const db = Datastore.create(path.join(__dirname, '../../db/quiz.db'));
8
+
9
+ // Seed default questions if empty
10
+ async function seedQuestions() {
11
+ const count = await db.count({});
12
+ if (count === 0) {
13
+ await db.insert([
14
+ { topic: 'JavaScript', question: 'What is closure?', options: ['A function inside a function', 'A loop', 'An array method', 'None'], answer: 0, difficulty: 'medium' },
15
+ { topic: 'JavaScript', question: 'What does "=== " mean?', options: ['Assignment', 'Loose equality', 'Strict equality', 'None'], answer: 2, difficulty: 'easy' },
16
+ { topic: 'React', question: 'What is JSX?', options: ['A database', 'JS + HTML syntax', 'A CSS framework', 'None'], answer: 1, difficulty: 'easy' },
17
+ { topic: 'Node.js', question: 'What is npm?', options: ['Node Package Manager', 'New Program Mode', 'None', 'Network Protocol'], answer: 0, difficulty: 'easy' },
18
+ { topic: 'CSS', question: 'What is flexbox used for?', options: ['Animations', 'Layout', 'Colors', 'Fonts'], answer: 1, difficulty: 'easy' },
19
+ ]);
20
+ }
21
+ }
22
+ seedQuestions();
23
+
24
+ // Get questions by topic
25
+ router.get('/:topic', async (req, res) => {
26
+ try {
27
+ const query = req.params.topic === 'all' ? {} : { topic: req.params.topic };
28
+ const questions = await db.find(query);
29
+ res.json(questions);
30
+ } catch (err) {
31
+ res.status(500).json({ error: err.message });
32
+ }
33
+ });
34
+
35
+ // Get all topics
36
+ router.get('/', async (req, res) => {
37
+ try {
38
+ const questions = await db.find({});
39
+ const topics = [...new Set(questions.map(q => q.topic))];
40
+ res.json(topics);
41
+ } catch (err) {
42
+ res.status(500).json({ error: err.message });
43
+ }
44
+ });
45
+
46
+ module.exports = router;
@@ -0,0 +1,43 @@
1
+
2
+ const express = require('express');
3
+ const router = express.Router();
4
+ const Datastore = require('nedb-promises');
5
+ const path = require('path');
6
+
7
+ const db = Datastore.create(path.join(__dirname, '../../db/snippets.db'));
8
+
9
+ // Get all snippets
10
+ router.get('/', async (req, res) => {
11
+ try {
12
+ const snippets = await db.find({}).sort({ createdAt: -1 });
13
+ res.json(snippets);
14
+ } catch (err) {
15
+ res.status(500).json({ error: err.message });
16
+ }
17
+ });
18
+
19
+ // Add snippet
20
+ router.post('/', async (req, res) => {
21
+ try {
22
+ const { title, code, language, tags } = req.body;
23
+ const snippet = await db.insert({
24
+ title, code, language, tags,
25
+ createdAt: new Date()
26
+ });
27
+ res.json(snippet);
28
+ } catch (err) {
29
+ res.status(500).json({ error: err.message });
30
+ }
31
+ });
32
+
33
+ // Delete snippet
34
+ router.delete('/:id', async (req, res) => {
35
+ try {
36
+ await db.remove({ _id: req.params.id });
37
+ res.json({ success: true });
38
+ } catch (err) {
39
+ res.status(500).json({ error: err.message });
40
+ }
41
+ });
42
+
43
+ module.exports = router;