{"id":28144500,"url":"https://github.com/back4app/antframework","last_synced_at":"2025-08-10T13:22:31.679Z","repository":{"id":57100133,"uuid":"139182412","full_name":"back4app/antframework","owner":"back4app","description":"Ant Framework - Serverless microservices made easy","archived":false,"fork":false,"pushed_at":"2018-11-05T18:41:36.000Z","size":572,"stargazers_count":12,"open_issues_count":11,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-03T17:04:44.501Z","etag":null,"topics":["api","graphql","microservices","serverless"],"latest_commit_sha":null,"homepage":"https://github.com/back4app/antframework#readme","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/back4app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-29T18:23:43.000Z","updated_at":"2024-06-26T09:50:04.000Z","dependencies_parsed_at":"2022-08-22T23:10:48.444Z","dependency_job_id":null,"html_url":"https://github.com/back4app/antframework","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/back4app%2Fantframework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/back4app%2Fantframework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/back4app%2Fantframework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/back4app%2Fantframework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/back4app","download_url":"https://codeload.github.com/back4app/antframework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170101,"owners_count":22026221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","graphql","microservices","serverless"],"created_at":"2025-05-14T22:12:39.414Z","updated_at":"2025-05-14T22:12:43.306Z","avatar_url":"https://github.com/back4app.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ant Framework\nAnt is an open-source and unopinionated framework to make microservices development easy.\n\n[Share your feedback](https://back4app.typeform.com/to/MnQl6C)\n\n## Quickstart\n### 1. Install the Ant CLI via npm\n\n```Shell\nnpm install -g @back4app/ant-cli\n```\n\n### 2. Create a new microservice\n\n```Shell\nant create MyService\n```\n\nAnt Framework will use the default template to create a brand new GraphQL service. Use --template option to select from many different templates and create other kind of services such as RESTful or SOAP APIs. [Learn more](#using-different-templates)\n\n### 3. Start the microservice in your localhost\n\n```Shell\ncd MyService\nant start\n```\n\n### 4. Play with your brand new GraphQL API\n\n![GraphiQL](https://ant.back4app.com/ant-sequence-01.gif)\n\nLearn more about GraphQL at [GraphQL official web-site](https://graphql.org/).\n\nExecute this example query:\n\n```GraphQL\nquery {\n    hello(name: \"Luke Skywalker\")\n}\n```\n\nThe default template brings to you an example query called `hello`. By customizing the GraphQL model and creating Ant Functions, you can develop your own GraphQL queries, mutations and subscriptions. [Learn more](#your-first-ant-function)\n\n### 5. Create your first Ant Function\nEdit the `model.graphql` file and use the following code:\n\n```GraphQL\nschema {\n  query: Query\n}\n\ntype Query {\n  hello(name: String = \"World\"): String @resolve(to: \"queryHello\")\n}\n```\n\nCreate a file called `queryHello.js` and use the following code:\n\n```JavaScript\nmodule.exports = ({ name }) =\u003e `Hello ${name} from function!!!`;\n```\n\nRun the following command:\n\n```Shell\nant function add queryHello ./queryHello.js Node\n```\n\nIt's done! Run and play with your brand new GraphQL API!\n\nYou can create any kind of query, mutation or subscription. You can use different runtimes to write code using your preferred programming language such as Node.js, Python, Java or C#. Learn more about [customizing your GraphQL model](#customizing-your-graphql-model) and [creating Ant Functions](#creating-ant-functions).\n\n### 6. Deploy to AWS Lambda via Serverless\n\n```Shell\naws configure\nant deploy\n```\n\nLearn more about how to setup the AWS CLI at [AWS official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).\n\nAnt Framework will use the default template to deploy the new service to your own AWS account Lambda via Serverless framework. Other templates can be used for choosing from many different providers and deploying to a wide range of scenarios of public and private clouds. [Learn more](#deploying-your-microservice)\n\n[Share your feedback](https://back4app.typeform.com/to/MnQl6C)\n\n## Concepts\n### Using the CLI tools\nAfter installed, you can use the framework core functionalities by running the `ant` command. To find out all core commands available, type `ant --help`.\n\n### Creating a new microservice\nIn order to create a new microservice, we can use the following command:\n\n```Shell\nant create \u003cservice\u003e [(--template|-t) (\u003ctemplate_name\u003e|\u003ctemplate_path\u003e)]\n```\n\nIt creates a new microservice based on the template provided, otherwise it will use the template located at the `lib/plugins/core/templates/services/default` directory by default. The default service template will include a GraphQL model and a plugin that allows you to start a GraphiQL server and test your service's endpoints.\n\n```Shell\nant create MyService # will create a MyService directory at the current working directory\ncd MyService\nant start # will run the GraphiQL server\n```\n\n##### Customizing your GraphQL model\nWithin your microservice directory will be the file `model.graphql`, which is be responsable for defining the model of your GraphQL server (it includes a query for testing purposes). There you can befine own your GraphQL schemas to be parsed by the GraphQL API.\n\n###### Using directives\nWIP\n\n1. @mock\nWIP\n\n2. @resolve\nWIP\n\n3. @sql\nWIP\n\n4. @mongo\nWIP\n\n5. @graphql\nWIP\n\n6. @parse\nWIP\n\n7. others\nWIP\n\n##### Creating Ant Functions\nWIP\n\n###### Using different runtimes\nWIP\n\n1. Node\nWIP\n\n2. Python\nWIP\n\n3. Java\nWIP\n\n4. C#\nWIP\n\n5. Others\nWIP\n\n##### Customizing your GraphQL server\nYou can fully customize your GraphQL server by changing the graphQL plugin configuration in your microservice configuration file under the key `server`. By default, the server initialized by the Ant framework is located at `lib/plugins/graphQL/templates/default/bin/server.js`, at port `3000`. To change the default model file (`model.graphql`), you will need to change the `model` parameter.\n\n```YAML\n- $GLOBAL/plugins/graphQL: # $GLOBAL is a variable that points to the Ant framework lib directory\n  {} # The default (empty) configuration implies in using the following values below\n  # The GraphQL plugin base path\n  # basePath: ./\n  # The GraphQL model path\n  # model: ./model.graphql\n  # The script to start the GraphQL API server when starting this service\n  # server:\n  #   bin: $GLOBAL/plugins/graphQL/templates/default/bin/server.js\n  #   port: 3000\n```\n\n##### Using different templates\nWIP\n\n###### GraphQL APIs\nWIP\n\n###### RESTful APIs\nWIP\n\n###### SOAP APIs\nWIP\n\n### Deploying your microservice\nWIP\n\n#### Working with Serverless framework\nWIP\n\n##### Deploying to AWS\nWIP\n\n##### Deploying to Azure\nWIP\n\n##### Deploying to Google Cloud\nWIP\n\n#### Working with Back4App\nWIP\n\n#### Working with Kubernetes\nWIP\n\n#### Creating your own deployment process\nWIP\n\n### Plugins\nWIP\n\n### Ant configuration files\nThere are two types of configuration file, the **Local** and the **Global**. The **Global** configuration file is located at `lib/globalConfig.yml`, and always will be used when your Ant instance is running. The **Local** configuration file is located at the current working directory, and will be created when any configuration file operation is done, such as adding new plugins or templates. The commands below can be used to make it easier to manipulate the configuration files:\n- `ant plugin add \u003cplugin\u003e [-g|--global]`: Adds a plugin into a configuration file. Can use the option -g to install into the global configuration file.\n- `ant plugin remove \u003cplugin\u003e [-g|--global]`: Removes a plugin from a configuration file. Can use the option -g to remove from the global configuration file.\n- `ant template ls`: Lists all templates available to use, considering the configuration files being used (can list templates from both local and global configurations).\n- `ant template add \u003ccategory\u003e \u003cname\u003e \u003cpath\u003e [-g|--global]`: Adds a template into a configuration file. The template is composed by a `category` (a name used as a helper to classify our templates), a `name` (which is basically an identification for the template inside a `category`), and a `template path` which is the path to the template files. Can use the option -g to install into the global configuration file.\n- `ant template remove \u003ccategory\u003e \u003cname\u003e [-g|--global]`: Removes a template from a configuration file. Can use the option -g to remove from the global configuration file.\n- `ant directive add \u003cname\u003e \u003cdefinition\u003e \u003chandler\u003e [runtime] [-c|--config]`: Adds a directive into a configuration file. Only available with the GraphQL plugin. It is needed to provide the directive name, its GraphQL definition, the path to the resolver function and its runtime, if different from default. Can use the -c option to manipulate a configuration file from a path different from the current working directory.\n- `ant directive remove \u003cname\u003e [-c|--config]`: Removes a directive from a configuration file by its name. Only available with the GraphQL plugin. Can use the -c option to manipulate a configuration file from a path different from the current working directory.\n- `ant directive ls [-c|--config]`: Lists all directives available to use. Can use the -c option to target a configuration file from a path different from the current working directory.\nAnt framework uses the YAML format on its configuration files. For more, check the links below:\n\n[Official YAML page](http://yaml.org/)\n\n[YAML Live Demo](http://nodeca.github.io/js-yaml/)\n\n## Extending the Ant Framework\nWIP\n\n### Creating your own templates\nWIP\n\n### Creating your own directives\nIt is possible to define your own directives by configuring them on the Ant's configuration file, under the GraphQL plugin configuration entry.\nThis configuration should respect the following format:\nrespect the following format, under the \"directives\" key:\n\n```YAML\n{\n  \u003cname\u003e: {\n    resolver: {\n      handler: \u003chandler\u003e,\n      runtime: \u003cruntime\u003e\n    },\n    definition: \u003cdefinition\u003e\n  }\n}\n```\n\nWhere:\n\n`\u003cname\u003e` is the Directive name;\n\n`\u003chandler\u003e` is the path to the function to resolve the Directive;\n\n`\u003cruntime\u003e` the runtime name to run the handler;\n\n`\u003cdefinition\u003e` the GraphQL definition of the directive, to be injected into the GraphQL schema.\n\nIf you wish to add your \"foo\" and \"bar\" directives, It could use the example below:\n\n```YAML\nplugins:\n  - $GLOBAL/plugins/graphQL: # Under the plugin entry goes our directives configuration\n      directives:\n        foo:\n          resolver:\n            handler: /my/foo.js # This file is going to be our directive resolver.\n            runtime: Node # This is name of the runtime to run our handler (it should be already configured on Ant)\n          definition: \"directive @foo(myParam: String, myOtherParam: Int) on FIELD_DEFINITION\" # This is what we inject into the GraphQL schema. Nothing more, nothing less.\n        bar:\n          resolver:\n            handler: /path/to/bar.py\n            runtime: Python\n          definition: \"directive @bar on FIELD_DEFINITION\" # In this case, we chose not to provide any parameters to the directive, and It is totally fine.\n```\n\nIt is also possible to handle the GraphQL directives from the configuration file by using the `directive add` and `directive remove` commands.\nThe example above could also be done by using the following commands:\n```\nant directive add foo \"directive @foo(myParam: String, myOtherParam: Int) on FIELD_DEFINITION\" /my/foo.js\nant directive add bar \"directive @bar on FIELD_DEFINITION\" /path/to/bar.py Python\n```\nNote that Node runtime was not needed to be provided in the first command because It is the default runtime.\n\nIf you wish to list all available directives, you can use the `directive ls` command.\n\n### Creating new runtimes\nWIP\n\n### Customizing providers\nWIP\n\n### Packaging new plugins\nWIP\n\n#### Customizing the CLI\nWIP\n\n## API Reference\n[API Reference](https://ant.back4app.com/docs/api/index.html)\n\n## Contributing\nWIP\n\n## License\nThe Ant framework is licensed under the [MIT](https://opensource.org/licenses/MIT) license.\n\n[Share your feedback](https://back4app.typeform.com/to/MnQl6C)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fback4app%2Fantframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fback4app%2Fantframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fback4app%2Fantframework/lists"}