Skip to content

Commit e16f8b4

Browse files
committed
Add NPM package info
1 parent 2781e4b commit e16f8b4

6 files changed

Lines changed: 84 additions & 50 deletions

File tree

README.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Django Task API
2+
===============
3+
4+
Django Task API lets you quickly write background tasks for your Django project and easily call then using the provided
5+
REST API, or the included JavaScript library.
6+
7+
What does it look like?
8+
-----------------------
9+
10+
Tasks are defined as classes with typed input and output parameters, and a `run` function with the task implementation,
11+
to be called by a worker processes.
12+
13+
.. code-block:: python
14+
15+
from task_api.tasks import Task
16+
from task_api.params import ListParameter, NumberParameter
17+
18+
class SumNumbers(Task):
19+
name = 'sum'
20+
21+
inputs = {
22+
'numbers': ListParameter(NumberParameter())
23+
}
24+
25+
outputs = {
26+
'sum': NumberParameter()
27+
}
28+
29+
def run(self, numbers):
30+
return sum(numbers)
31+
32+
Tasks are easily called and monitored in front-end code using the included JavaScript API. The API supports both
33+
promises (will Polyfill for older browsers) and traditional callbacks.
34+
35+
.. code-block:: html
36+
37+
<script src="{% static 'django-task-api.js' %}"></script>
38+
39+
<script type="text/javascript">
40+
function sumTask(numbers) {
41+
TaskAPI
42+
.run('sum', {'numbers': numbers})
43+
.then(function(json) {
44+
console.log('Sum: ' + json.outputs.sum)
45+
})
46+
}
47+
</script>
48+
49+
Next Steps
50+
----------
51+
52+
* :doc:`start`
53+
* `GitHub <https://github.com/nikmolnar/django-task-api>`_

javascript/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Nikolas Stevenson-Molnar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

javascript/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# django-task-api
2+
3+
A JavaScript client library for [Django Task API](https://github.com/nikmolnar/django-task-api)

javascript/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
"name": "django-task-api",
33
"version": "1.0.0",
44
"description": "Client library for the Django Task API",
5-
"main": "src/index.js",
5+
"main": "dist/django-task-api.min.js",
6+
"module": "src/index.js",
7+
"files": [
8+
"dist",
9+
"src"
10+
],
611
"scripts": {
712
"build": "webpack --config webpack.config.babel.js && cp dist/django-task-api.js ../task_api/static/"
813
},

javascript/webpack.config.babel.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from 'path'
2-
import webpack from 'webpack'
32
import UglifyJsPlugin from 'uglifyjs-webpack-plugin'
43

54
export default {
@@ -21,7 +20,7 @@ export default {
2120
]
2221
},
2322
output: {
24-
filename: 'django-task-api.js',
23+
filename: 'django-task-api.min.js',
2524
path: path.resolve(__dirname, 'dist'),
2625
library: 'TaskAPI'
2726
},

0 commit comments

Comments
 (0)