Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template fixes #1079

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/agents/spec_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ async def initialize_spec(self) -> AgentResponse:
if len(user_description) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
initial_spec = await self.analyze_spec(user_description)
reviewed_spec = await self.review_spec(desc=user_description, spec=initial_spec)
else:
initial_spec = reviewed_spec = user_description

self.next_state.specification = self.current_state.specification.clone()
self.next_state.specification.original_description = user_description
Expand Down
7 changes: 3 additions & 4 deletions core/templates/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

from .javascript_react import JavascriptReactProjectTemplate
from .node_express_mongoose import NodeExpressMongooseProjectTemplate

# from .react_express import ReactExpressProjectTemplate
from .react_express import ReactExpressProjectTemplate

log = get_logger(__name__)

Expand All @@ -15,11 +14,11 @@ class ProjectTemplateEnum(str, Enum):

JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name
NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name
# REACT_EXPRESS = ReactExpressProjectTemplate.name
REACT_EXPRESS = ReactExpressProjectTemplate.name


PROJECT_TEMPLATES = {
JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate,
NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate,
# ReactExpressProjectTemplate.name: ReactExpressProjectTemplate,
ReactExpressProjectTemplate.name: ReactExpressProjectTemplate,
}
2 changes: 1 addition & 1 deletion core/templates/tree/react_express/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ app.use(cors());
{% if options.auth %}

// Authentication routes
app.use(authRoutes);
app.use(authenticateWithToken);
app.use(authRoutes);
{% endif %}

app.use(apiRoutes);
Expand Down
4 changes: 4 additions & 0 deletions core/templates/tree/react_express/api/routes/authRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ router.post('/api/auth/password', requireUser, async (req, res) => {
res.status(204).send();
});

router.get('/api/auth/me', requireUser, async (req, res) => {
return res.status(200).json(req.user);
});

export default router;
12 changes: 12 additions & 0 deletions core/templates/tree/react_express/ui/main.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if options.auth %}
import axios from 'axios'
{% endif %}
import React from 'react'
import ReactDOM from 'react-dom/client'
import { createBrowserRouter, RouterProvider, useLocation } from "react-router-dom"
Expand All @@ -9,6 +12,15 @@ import Home from './pages/Home.jsx'
{% if options.auth %}
import Register from './pages/Register.jsx'
import Login from './pages/Login.jsx'

// Add auth token to every API request if we have it
axios.interceptors.request.use(config => {
const token = localStorage.getItem("token");
if (token && !config.headers.Authorization) {
config.headers.Authorization = `Token ${token}`
}
return config
})
{% endif %}

function PageNotFound() {
Expand Down
Loading