master 4f1fba6c7b7d cached
7 files
3.3 KB
1.1k tokens
1 requests
Download .txt
Repository: generalgmt/RESTfulAPITutorial
Branch: master
Commit: 4f1fba6c7b7d
Files: 7
Total size: 3.3 KB

Directory structure:
gitextract_9ir2vwol/

├── .gitignore
├── README.md
├── api/
│   ├── controllers/
│   │   └── todoListController.js
│   ├── models/
│   │   └── todoListModel.js
│   └── routes/
│       └── todoListRoutes.js
├── package.json
└── server.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
logs
*.log
npm-debug.log*
node_modules
.npm
.DS_Store


================================================
FILE: README.md
================================================
## Nodejs in 10 minutes

clone the project

### Installations
* npm install

### Run

* npm run start

:)

================================================
FILE: api/controllers/todoListController.js
================================================
'use strict';

var mongoose = require('mongoose'),
  Task = mongoose.model('Tasks');



exports.list_all_tasks = function(req, res) {
  Task.find({}, function(err, task) {
    if (err)
      res.send(err);
    res.json(task);
  });
};


exports.create_a_task = function(req, res) {
  var new_task = new Task(req.body);
  new_task.save(function(err, task) {
    if (err)
      res.send(err);
    res.json(task);
  });
};

exports.read_a_task = function(req, res) {
  Task.findById(req.params.taskId, function(err, task) {
    if (err)
      res.send(err);
    res.json(task);
  });
};

exports.update_a_task = function(req, res) {
  Task.findOneAndUpdate({_id:req.params.taskId}, req.body, {new: true}, function(err, task) {
    if (err)
      res.send(err);
    res.json(task);
  });
};
// Task.remove({}).exec(function(){});
exports.delete_a_task = function(req, res) {

  Task.remove({
    _id: req.params.taskId
  }, function(err, task) {
    if (err)
      res.send(err);
    res.json({ message: 'Task successfully deleted' });
  });
};


================================================
FILE: api/models/todoListModel.js
================================================
'use strict';


var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var TaskSchema = new Schema({
  name: {
    type: String,
    Required: 'Kindly enter the name of the task'
  },
  Created_date: {
    type: Date,
    default: Date.now
  },
  status: {
    type: [{
      type: String,
      enum: ['pending', 'ongoing', 'completed']
    }],
    default: ['pending']
  }
});


module.exports = mongoose.model('Tasks', TaskSchema);

================================================
FILE: api/routes/todoListRoutes.js
================================================
'use strict';

module.exports = function(app) {
	var todoList = require('../controllers/todoListController');

	// todoList Routes
	app.route('/tasks')
		.get(todoList.list_all_tasks)
		.post(todoList.create_a_task);

	app.route('/tasks/:taskId')
		.get(todoList.read_a_task)
		.put(todoList.update_a_task)
		.delete(todoList.delete_a_task);
};


================================================
FILE: package.json
================================================
{
  "name": "todolistapi",
  "version": "1.0.0",
  "description": "RESTful todoListApi",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon server.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/generalgmt/RESTfulAPITutorial.git"
  },
  "keywords": [
    "RESTful",
    "API",
    "Tutorial"
  ],
  "author": "olatunde garuba",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/generalgmt/RESTfulAPITutorial/issues"
  },
  "homepage": "https://github.com/generalgmt/RESTfulAPITutorial#readme",
  "devDependencies": {
    "nodemon": "^1.11.0"
  },
  "dependencies": {
    "body-parser": "^1.15.2",
    "express": "^4.14.0",
    "mongoose": "^5.7.7"
  }
}


================================================
FILE: server.js
================================================
var express = require('express'),
  app = express(),
  port = process.env.PORT || 3000,
  mongoose = require('mongoose'),
  Task = require('./api/models/todoListModel'),
  bodyParser = require('body-parser');

mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/Tododb');


app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());


var routes = require('./api/routes/todoListRoutes');
routes(app);

app.use(function(req, res) {
  res.status(404).send({url: req.originalUrl + ' not found'})
});

app.listen(port);

console.log('todo list RESTful API server started on: ' + port);
Download .txt
gitextract_9ir2vwol/

├── .gitignore
├── README.md
├── api/
│   ├── controllers/
│   │   └── todoListController.js
│   ├── models/
│   │   └── todoListModel.js
│   └── routes/
│       └── todoListRoutes.js
├── package.json
└── server.js
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
  {
    "path": ".gitignore",
    "chars": 54,
    "preview": "logs\n*.log\nnpm-debug.log*\nnode_modules\n.npm\n.DS_Store\n"
  },
  {
    "path": "README.md",
    "chars": 105,
    "preview": "## Nodejs in 10 minutes\n\nclone the project\n\n### Installations\n* npm install\n\n### Run\n\n* npm run start\n\n:)"
  },
  {
    "path": "api/controllers/todoListController.js",
    "chars": 1041,
    "preview": "'use strict';\n\nvar mongoose = require('mongoose'),\n  Task = mongoose.model('Tasks');\n\n\n\nexports.list_all_tasks = functio"
  },
  {
    "path": "api/models/todoListModel.js",
    "chars": 446,
    "preview": "'use strict';\n\n\nvar mongoose = require('mongoose');\nvar Schema = mongoose.Schema;\n\nvar TaskSchema = new Schema({\n  name:"
  },
  {
    "path": "api/routes/todoListRoutes.js",
    "chars": 345,
    "preview": "'use strict';\n\nmodule.exports = function(app) {\n\tvar todoList = require('../controllers/todoListController');\n\n\t// todoL"
  },
  {
    "path": "package.json",
    "chars": 767,
    "preview": "{\n  \"name\": \"todolistapi\",\n  \"version\": \"1.0.0\",\n  \"description\": \"RESTful todoListApi\",\n  \"main\": \"index.js\",\n  \"script"
  },
  {
    "path": "server.js",
    "chars": 624,
    "preview": "var express = require('express'),\n  app = express(),\n  port = process.env.PORT || 3000,\n  mongoose = require('mongoose')"
  }
]

About this extraction

This page contains the full source code of the generalgmt/RESTfulAPITutorial GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (3.3 KB), approximately 1.1k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!